Asked by Indu Muthancheri
on 14 Jun 2018

One of my differential equation contains a term deltat. How do I access the time step of every ode solver iteration within the differential equation function.

[t,y]=ode45(@xx,tspan,yo);

%%in function xx

function dydt=xx(t,y)

dydt=zeros(3,1);

dydt(1)=A*deltat; %deltat is the time step during that iteration

dydt(2)=f(y(1),y(2),....)

dydt(3)=f(y(1),y(2)....)

end

Thank you so much in advance for the help!

Answer by Jan
on 14 Jun 2018

deltat is the time step during that iteration

This is not a meaningful statement. Remember that ODE45 evaluates the equation several times for each step. Afterwards it uses an error control and rejects a step, when the tolerances are exceeded. It is impossible, that the mathematical notation will or can consider this. So please explain exactly, which mathematical problem you want to solve.

Jan
on 14 Jun 2018

Indu Muthancheri
on 14 Jun 2018

Sign in to comment.

Answer by James Tursa
on 14 Jun 2018

James Tursa
on 14 Jun 2018

Indu Muthancheri
on 14 Jun 2018

James Tursa
on 14 Jun 2018

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## James Tursa (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405707-in-ode-solver-how-to-use-the-time-step-of-each-iteration-within-the-differential-equation#comment_578797

## Indu Muthancheri (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/405707-in-ode-solver-how-to-use-the-time-step-of-each-iteration-within-the-differential-equation#comment_578856

Sign in to comment.