Azzera filtri
Azzera filtri

Finding Corresponding X Value for Y value

2 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Les Beckham
Les Beckham il 21 Feb 2022
Modificato: Les Beckham il 21 Feb 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

Più risposte (0)

Categorie

Scopri di più su Structures in Help Center e File Exchange

Tag

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by