Matlab integration with one integration step in matlab ode suite
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Scipy integration allows us to do ode integration one adaptive timestep at a time and do something to it. However, matlab ode needs us to specify a [timespan][1] , and determine the adaptive timestep within, but cannot do things within.
[1]: https://www.mathworks.com/help/matlab/ref/ode45.html#inputarg_tspan
From scipy
ODE.set_initial_value(y0, tlist[0])
numoftimes = len(tlist)
for ii in range(1, numoftimes):
# while loop up to tlist[ii]
while ODE.t < tlist[ii]:
t_prev = ODE.t
y_prev = ODE.y
# integrate up to tlist[ii], one step at a time.
ODE.integrate(tlist[ii], step=1)
#do something to the output
...
However, in matlab, I failed to do this, mainly `step=1` is not available in matlab ode suite.
Attempt is to make the tspan extremely small in matlab ode suite. But this is then not adaptive. In some region the original ode timestep is very big (non-stiff), but at some regions the ode timestep is very small (stiff).
tlist = [0 tf]
numoftimes = len(tlist)
for ii = 1:numoftimes
# while loop up to tlist(ii)
while t_prev < tlist(ii)
t_prev = T(end,:)
y_prev = Y(end,:)
# integrate up to tlist(ii), one step at a time.
t = [t_prev,t_prev+0.0000000000001];
[T, Y] = ode45(dydt, t, y);
#do something to the output
...
end
end
This then is not good as I have, even if the ode45 does integrate with only 1 step 1. force the timestep to be fixed interval 2. time-consuming as in some non-stiff region the "original adaptive" timestep needs not be that small.
How can I solve this with matlab ode suite?
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!