plotting equation in matlab
I am trying to plot equation in matlab for days now and I can't get it look right. This is for school so I know how the end result should look like. I get something similar but not the same.
This is the plot I should get:
under the pic it says that I should use equation 5.8 but I think that it is impossible to get this curve with it because it only gives one result and on plot is show as a dot here is the equation 5.8:
If you read first few lines above it I think it is obvious that there was a printing error and that I should use equation 5.6 (but i am not sure) so here is equation 5.6:
Also the data needed for the equation is given above 5.6. This is my Matlab code for it:
p1=1.581; p2=-5.534; p3=0.5523; om1=1.214; om2=0.001414; om3=2.401; c1=-0.3132; c2=3.297; c3=-2.381; t=0:0.5:5 Ca=0.2132; Ra=2.275; V1=(p1*Ca*(sin(om1*t+c1)-om1*Ra*Ca*cos(om1*t+c1)))/(1+(om1^2)*(Ra*Ca)^2) V2=(p2*Ca*(sin(om2*t+c2)-om2*Ra*Ca*cos(om2*t+c2)))/(1+(om2^2)*(Ra*Ca)^2) V3=(p3*Ca*(sin(om3*t+c3)-om3*Ra*Ca*cos(om3*t+c3)))/(1+(om3^2)*(Ra*Ca)^2) V=V1+V2+V3 plot(t,V,'.')
Here is what I get:
So instead of zero at t=0 i get a negative number, and same holds for t=4:5. What is my error is it the wrong equation or is my code bad?
Here is a plot using your code, except that I used
which looks quite similar to the book's figure. I agree that the exponential term is probably the reason for the difference close to zero.