Plotting two time dependant graphs with MATLAB -
basically, have 2 functions. p1 , p2.
p1 kicks in @ t=0 , runs few seconds (a trig function). p2 starts, it's , exponential decay.
below i'm trying do.
i've tried create time matrix , ode solver. need way of plotting both functions on sigle graph,.
any highly appreciated.
alpha=20 beta=4.9139 h0=-0.0116 a=959; p01=100; p02=100; r=0.5; c=0.1;
from t01-t1 (0.639s)
h=(exp(alpha*t1)/(alpha^2)+(beta^2)).*(alpha*sin(beta*t1)-belta*cos(beta*t1)); g=(a*h0/c)-p01; p1=((a*h)/(c-g))*exp(-t1/r*c);
then: t02-t2 (1.278s)
p2=p02*exp(-t2/(r*c))
with
alpha=20; beta=4.9139; h0=-0.0116; a=959; p01=100; p02=100; r=0.5; c=0.1; t1 = 0:0.001:0.639; h=(exp(alpha*t1)/(alpha^2)+(beta^2)).*(alpha*sin(beta*t1)-beta*cos(beta*t1)); g=(a*h0/c)-p01; p1=((a*h)/(c-g)).*exp(-t1/r*c); t2 = 0.639:0.001:1.278; p2=p02*exp(-t2/(r*c));
i.e. defining time vectors t1 , t2 going steps of 0.001s, following graph (note multiplied p2 10^8, because y-scales rather different.
figure,plot(t1,p1,'r',t2,p2*1e8,'g')
Comments
Post a Comment