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!
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.
Based on your description, I would conclude that the deltat in the equation is simply the total amount of time that the mass flow rate has been taking place. If you start the simulation at time 0 and pass in t to your derivative routine, then you can simply use t in place of deltat in your MATLAB code.