Borrar filtros
Borrar filtros

Finding Corresponding X Value for Y value

2 visualizaciones (últimos 30 días)
Collin McKenzie
Collin McKenzie el 21 de Feb. de 2022
Editada: Les Beckham el 21 de Feb. de 2022
Looking to find the corresponding X value for the maximum force P in my force vs. displacement graph.
P=zeros(1,750);
theta=zeros(1,750);
L=zeros(1,750);
F=zeros(1,750);
W=10;
g=9806;
for x = 1:750
theta(x)=atand(400/x);
L(x)=sqrt((x^2)+(400^2));
F(x)=W*g*cosd(theta(x))*500;
P(x)=F(x)/L(x);
end
plot(1:750,P)
xlabel('x in mm')
ylabel('P in kg/mm/s^2')
Pmax= max(P);
fprintf('The maximum P value in kg/mm/s^2 is: %0.2f \n',Pmax);

Respuesta aceptada

Les Beckham
Les Beckham el 21 de Feb. de 2022
Editada: Les Beckham el 21 de Feb. de 2022
If you ask for two outputs from the max() function you can find the index of your peak:
P=zeros(1,750);
theta=zeros(1,750);
L=zeros(1,750);
F=zeros(1,750);
W=10;
g=9806;
for x = 1:750
theta(x)=atand(400/x);
L(x)=sqrt((x^2)+(400^2));
F(x)=W*g*cosd(theta(x))*500;
P(x)=F(x)/L(x);
end
plot(1:750,P)
xlabel('x in mm')
ylabel('P in kg/mm/s^2')
[Pmax, index] = max(P);
fprintf('The maximum P value in kg/mm/s^2 is: %0.2f at x = %d mm\n', Pmax, index);
The maximum P value in kg/mm/s^2 is: 61287.50 at x = 400 mm

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by