フィルターのクリア

Finding Corresponding X Value for Y value

2 ビュー (過去 30 日間)
Collin McKenzie
Collin McKenzie 2022 年 2 月 21 日
編集済み: Les Beckham 2022 年 2 月 21 日
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);

採用された回答

Les Beckham
Les Beckham 2022 年 2 月 21 日
編集済み: Les Beckham 2022 年 2 月 21 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by