Simple plotting problem of a function

조회 수: 11 (최근 30일)
Isa
Isa 2012년 10월 23일
Hi, I am new at Matlab and I want to plot a graph of a spring's displacement in relation with the person height (H). I wrote the following in the MatLab editor (The three important lines are the three last ones) :
rad=pi/180; %To convert degress into radiant
deg=180/pi; %To convert radiant into degrees
C1=0.088*H+0.03;
C2=0.036*H+0.04;
C3=0.02*H;
C4=0.153*H;
teta1=360-118-90-atan(C1/C4)*deg-atan(C2/C3)*deg;
teta2=360-80-90-atan(C1/C4)*deg-atan(C2/C3)*deg;
PO=sqrt(C1^2+C4^2);
AO=sqrt(C2^2+C3^2);
L1=sqrt(PO^2+AO^2-2*PO*AO*cos(teta1*rad));
L2=sqrt(PO^2+AO^2-2*PO*AO*cos(teta2*rad));
SpringDisplacement=L2-L1;
H=1:0.01:2;
ezplot('SpringDisplacement(H)');
The error message when I press RUN MATLAB is : ??? Undefined function or method 'Matlab' for input arguments of type 'char'. And I do not know when I should use ezplot or plot? I am really new at this program so explanation of my errors would be greatly appreciated! Thank you,
  댓글 수: 1
Isa
Isa 2012년 10월 23일
So I put . after so each elements of the list are squared instead of matrix multiplications. Also using plot() after the changes made it work .
rad=pi/180; %To convert degress into radiant
deg=180/pi; %To convert radiant into degrees
C1=0.088*H+0.03;
C2=0.036*H+0.04;
C3=0.02*H;
C4=0.153*H;
teta1=360-118-90-atan(C1/C4)*deg-atan(C2/C3)*deg;
teta2=360-80-90-atan(C1/C4)*deg-atan(C2/C3)*deg;
PO=sqrt(C1.^2+C4.^2);
AO=sqrt(C2.^2+C3.^2);
L1=sqrt(PO.^2+AO.^2-2*PO.*AO.*cos(teta1*rad));
L2=sqrt(PO.^2+AO.^2-2*PO.*AO.*cos(teta2*rad));
SpringDisplacement=L2-L1;
H=1:0.01:1.9; %Min height of person is 1m, maximum height is 1.9m
plot(SpringDisplacement,H)
The values from the plot seem to correspond with what I am looking for so I am assuming it is right

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by