cumulatives of the dynamical system

2 visualizzazioni (ultimi 30 giorni)
alpedhuez
alpedhuez il 26 Mag 2020
Modificato: alpedhuez il 28 Mag 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?

Risposta accettata

Walter Roberson
Walter Roberson il 26 Mag 2020
Modificato: Walter Roberson il 26 Mag 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

Più risposte (0)

Tag

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by