Matlab integration without timespan in matlab ode suite
<p>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 <a href="https://www.mathworks.com/help/matlab/ref/ode45.html#inputarg_tspan" rel="nofollow noreferrer">timespan</a> , and determine the adaptive timestep within, but cannot do things within.</p>

<p>From scipy </p>

<pre><code>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 &lt; 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
        ...
</code></pre>

<p>However, in matlab, I failed to do this, mainly <code>step=1</code> is not available in matlab ode suite.</p>

<p>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).</p>

<pre><code>tlist = [0 tf]    
numoftimes = len(tlist)
for ii = 1:numoftimes
     # while loop up to tlist(ii)
     while t_prev &lt; 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
</code></pre>

<p>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.</p>

<p>How can I solve this with matlab ode suite?</p>