How to fix the time step in ODE45
Show older comments
I want to fix the time step for my ode45 function. The code which I am using is as follows:
dt = 0.02;
tf = 600;
t = dt:dt:tf;
y0 = zeros(14,1);
[tout,yout] = ode45(@OC3_odefull,t,y0);
When I run my code, I have no control over the time step size and ode45 uses an adaptive time step. Is there any way that I can force ode45 to use the time step that I want?
2 Comments
Jan
on 8 Jul 2018
The "45" means, that each step is calculated with an order 4 and order 5 method. The difference between the results is used to control the step size. It is not meaningful to run an ODE45 method with a fixed step size.
Abla Nevame Edzenunye
on 12 Oct 2022
Thank you!!!
Accepted Answer
More Answers (1)
Walter Roberson
on 7 Jul 2018
2 votes
No, you cannot do that.
Officially, Mathworks only provides variable step solvers for MATLAB use.
Unofficially, see https://www.mathworks.com/matlabcentral/answers/98293-is-there-a-fixed-step-ordinary-differential-equation-ode-solver-in-matlab-8-0-r2012b#answer_107643 for the fixed step routines ode1 through ode5 .
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!