Plotting Two time dependant graphs at once

In summary, the conversation discusses two functions, P1 and P2, that have different behaviors. P1 starts at t=0 and has a trigonometric function while P2 begins after a few seconds and has an exponential decay. The goal is to plot both functions on a single graph. The conversation also mentions using a time matrix and ode solver to solve the functions. The formula for P1 and P2 are given, and the conversation suggests creating two functions that are equal to 1 within specific time intervals and 0 otherwise, and then multiplying them with the corresponding function to plot and check the results. A link to a helpful web page is also mentioned.
  • #1
kian651
3
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
  • #2
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
 

Related to Plotting Two time dependant graphs at once

1. How do I plot two time dependent graphs at once?

To plot two time dependent graphs at once, you will need to use a software or programming language that allows for multiple graph plotting. Some common options include MATLAB, Python, and R. In these programs, you can use the command to plot multiple graphs on the same figure or use subplots to display them side by side.

2. Can I plot two graphs with different time scales at once?

Yes, it is possible to plot two graphs with different time scales at once. You can use the "hold on" function in MATLAB or the "add_subplot" function in Python and R to add multiple axes to a single figure and plot each graph on a different axis with its own time scale.

3. How do I label each graph on the same figure?

To label each graph on the same figure, you can use the "legend" function in MATLAB or the "plt.legend" function in Python and R. This will create a legend that identifies each graph by its label or color.

4. Is it possible to plot two time dependent graphs with different units?

Yes, it is possible to plot two time dependent graphs with different units. You can use the "yyaxis" function in MATLAB or the "axes.twinx" function in Python and R to create a secondary y-axis and plot the second graph with its own units on this axis.

5. How can I compare the trends of two time dependent graphs?

To compare the trends of two time dependent graphs, you can plot them on the same figure and use a similar scale for both graphs. You can also use different colors or line styles to differentiate between the two graphs. Additionally, you can calculate statistical measures such as correlation coefficient or slope to determine the relationship between the two graphs.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
3K
  • Introductory Physics Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
  • Biology and Chemistry Homework Help
Replies
2
Views
14K
  • Engineering and Comp Sci Homework Help
Replies
15
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
10K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
Back
Top