필터 지우기
필터 지우기

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 CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by