I’m using Matlab to solve a differential equation. I want to force ode45 to take constant steps, so it always increments 0.01 on the T axis while solving the equation. How do I do this?
ode45 is consistently taking optimized, random steps, and I can’t seem to work out how to make it take consistent, small steps of 0.01. Here is the code:
options= odeset('Reltol',0.001,'Stats','on');
%figure(1);
%clf;
init=[xo yo zo]';
tspan=[to tf];
%tspan = t0:0.01:tf;
[T,Y]=ode45(name,tspan,init,options);
Based on the documentation it doesn’t appear that you can control the size of the steps taken internally by
ode45when solving the equation, but you can control the time points at which the output is generated. You can do this as indicated in your commented-out line:With respect to the accuracy of solutions when fixed step sizes are used, refer to this excerpt from the above link:
So, even when you specify that you want the solution at specific time points in the output, the solvers are still internally taking a number of adaptive steps between the time points that you indicate, coming close to the values at those fixed time points.