2
votes

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:

enter image description here

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:

enter image description here

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:

enter image description here

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:

enter image description here

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?

1
Are you deliberately omitting the exponential term? Also, from the caption to Fig. 5.3, Ca may actually equal 0.21321 (there's a strange space before the last one) – not sure if that would make any difference. - horchler
Yea it says i should omit it and i dont have valu for H so i cant put it in eqvasion and try to see would it make any difference. I have also noticed different valus for Ca and tried bout not any visible difference on diag i think it is typo and that Ca is 0.2132. And sorry for bad english and plz help - user3253620
A value for H should not be to hard to derive if you want V(t=0)=0, because exp(-t/(Ra*Ca)) is one for t is zero. So H would be -(V1(1)+V2(1)+V3(1)). - fibonatic
Your code looks fine to me. I can only think that the plot actually may incorporate an exponential term. - horchler
Tnx so can somebady help me incorporate it sence i dont know valu of H. And would it make plot look like it should? Also do you agree with me that i should use eqvasion 5.6 and that 5.8 is typo? - user3253620

1 Answers

0
votes

Here is a plot using your code, except that I used

t=0:0.05:5;

a plot

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.