MATLAB: Change step size in MATLAB for ODE45

ode45size;smallest valuesteptime

Hi, is it possible to avoid this:
Warning: Failure at t=-3.000000e+00. Unable to meet integration tolerances without reducing the step size below the smallest value
allowed (7.105427e-15) at time t.
> In ode45 (line 308)
In S_plot (line 6)
I would need to go far lower, type 10^-104

Best Answer

If the step size controller of ODE45 reaches 7e-15, the integration will take many years of processing time: Remember, that a day has less than 1e5 seconds only and even if ODE45 would get 1 million iterations per second, the number of steps is still huge.
Such a tiny step size is a secure indicator of either a discontinuity, a pole or a stiff equation. Reducing the step size is not a valid option, because this increases the run time (see above) and the accumulated rounding errors due to the massive number of steps. You have to examine the function mathematically instead. Maybe a stiff solver is better or avoiding the pole.
Related Question