Plotting Two time dependant graphs at once

AI Thread Summary
The discussion revolves around plotting two functions, P1 and P2, on a single graph. P1 is a trigonometric function that activates at t=0 and runs for a short duration, while P2 represents an exponential decay that starts after P1. The user has attempted to create a time matrix and use an ODE solver but is struggling to visualize both functions together. Key parameters include alpha, beta, H0, A, P01, P02, R, and C, which are integral to the calculations for both functions. A suggested approach involves creating binary functions that activate during specific time intervals for P1 and P2, multiplying these with their respective functions, and then plotting the results to verify the combined output. A link to a relevant MathWorks page is provided for additional assistance.
kian651
Messages
3
Reaction score
0
Basically, we have two functions. P1 and P2.

P1 Kicks in at t=0 and runs for a few seconds (a trig function). Then P2 starts, it's and exponential decay.

Below is what I'm trying to do.

I've tried to create time matrix and even ode solver. I need a way of plotting both functions on a sigle graph,.

Any help is 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))


I've tried and tried but don't know how it works,
 
Physics news on Phys.org
See if you might be able to apply this idea: Suppose you create a function that = 1 from T01 to T1 and = 0 elsewhere. Multiply your H times that function. Plot that to check it correctly does the first part of what you need. Suppose you create a second function that = 1 from T02 to T2 and = 0 elsewhere. Multiply your P2 times that function. Plot again to check. Now what do you get if you add the first product and the second? Plot and check.

Perhaps this web page might help
http://www.mathworks.com/matlabcentral/newsreader/view_thread/299504
 
Back
Top