cumulatives of the dynamical system
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
alpedhuez
am 26 Mai 2020
Bearbeitet: alpedhuez
am 28 Mai 2020
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Mai 2020
Bearbeitet: Walter Roberson
am 26 Mai 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
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!