Plotting Two time dependant graphs at once

Click For Summary
SUMMARY

The discussion focuses on plotting two time-dependent functions, P1 and P2, where P1 is a trigonometric function activated at t=0 and P2 is an exponential decay function starting later. The user has attempted to create a time matrix and utilize an ODE solver but seeks assistance in visualizing both functions on a single graph. Key parameters include alpha=20, beta=4.9139, H0=-0.0116, A=959, P01=100, P02=100, R=0.5, and C=0.1. The user suggests creating binary functions to isolate the time intervals for each function and then combining the results for plotting.

PREREQUISITES
  • Understanding of trigonometric functions and exponential decay
  • Familiarity with MATLAB or similar plotting tools
  • Knowledge of ODE solvers and time matrices
  • Basic programming skills for function creation and manipulation
NEXT STEPS
  • Learn MATLAB plotting techniques for time-dependent functions
  • Explore MATLAB's ODE solver capabilities for function analysis
  • Research binary function creation for isolating time intervals
  • Investigate combining multiple plots in MATLAB for visual clarity
USEFUL FOR

Mathematicians, data analysts, and engineers interested in visualizing complex time-dependent functions, particularly those using MATLAB for simulations and graphical representations.

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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
7
Views
3K
  • · Replies 1 ·
Replies
1
Views
14K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
11K
  • · Replies 15 ·
Replies
15
Views
6K
Replies
1
Views
2K
Replies
6
Views
13K