MATLAB: How to access to the past time step in ODE45

ode45

Hi all, I am solving a set of ODE equations that in the fist equation I need the last time step (del_t) for example equations are as follows:
dA/dt=f(A,B)+G(del_t)
dB/dt=f(A,B)
My only problem is that I couldn't access the time step in the ODE.
Do anyone have suggestion?
Thank you in advance for your suggestions.
Best Regards
Aref

Best Answer

What do you intend by ‘last time step’?
You do not need them while your ODE is being integrated (for example by ode45). The very last time in the result:
[t,y] = ode45(@odefun, tspan, init_cond);
will be t(end). If you want the time interval between the last two integration times, you can calculated it as:
delta_t = t(end)-t(end-1);
Related Question