ODE 45 integration control
Show older comments
I've been having some issues with running ODE45 on a model that is very flat unless forced with a very short duration square wave, in which case it forms a spike and returns to the baseline. The adaptive time step of ODE45 is causing the time step to be larger than the interval the model is forced for, and skipping the spikes (unless by chance, one of the t values lies in the forcing interval).
Is there any way to control the internal time steps used by the solver? I would like to be able to supply a list of time values and ensure that ode45 evaluates my function at those points. Elsewhere it can do what it likes I just need to make sure the function is evaluated within the forcing interval to trigger the shorter step size.
Many thanks,
Harry
Accepted Answer
More Answers (1)
Mischa Kim
on 2 May 2014
Harry, in
...
tspan = linspace(0,1,11);
options = odeset('AbsTol',1e-8);
[t,X] = ode45(@ODE,tspan,IC,options);
for which the solver returns the solution at specific data points defined by tspan. You can further use the options vector with odeset to control other solver options such as tolerances, step size, etc.
Categories
Find more on Classical Control Design 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!