cumulatives of the dynamical system
1 view (last 30 days)
Show older comments
Suppose I have
where D(t) is the deaths at time t and solve the differential equation using ODE45. I now want to calculate the cumulative death
One way might be to take the sum of D(t) over all the steps. Is there a better way?
0 Comments
Accepted Answer
Walter Roberson
on 26 May 2020
Edited: Walter Roberson
on 26 May 2020
You currently have a first order differential equation, diff(D,t) == x(t). When you use it with ode45 you would be using a function such as
odefun = @(t,x) X(t);
and the output you would get from this would be D, the integration of the system.
Now to get the integral of D, you can reframe it as a second order differential equation:
dE(t)/dt = D(t)
dD(t)/Dt = X(t)
odefun = @(t,x) [x(2); X(x(2))]
[t, X] = ode45(odefun, [0 1], E0) %E0 is boundary conditions D(0) and D'(0)
output = X(end,1)
That is, since what ode45 already does is numeric integration, then you can just add in another layer to tell it to do integration of D
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!