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 , and determine the adaptive timestep within, but cannot do things within.
ODE.set_initial_value(y0, tlist) 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.
Which ODE solver in Matlab allows me to advance in just one timestep only
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?