Change step size in MATLAB for ODE45
59 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sergio Manzetti
am 9 Mär. 2018
Kommentiert: Steven Lord
am 9 Mär. 2018
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
2 Kommentare
Torsten
am 9 Mär. 2018
Depends on the ODE you are trying to solve.
What do you mean by "I would need to go far lower, type 10^-104" ?
Akzeptierte Antwort
Jan
am 9 Mär. 2018
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.
4 Kommentare
Steven Lord
am 9 Mär. 2018
The warning message talks about t rather than time or x because of the way the help text and documentation describes the input. From the documentation for ode45:
"[t,y] = ode45(odefun,tspan,y0), where tspan = [t0 tf], integrates the system of differential equations y'=f(t,y) from t0 to tf with initial conditions y0."
and
"The function dydt = odefun(t,y), for a scalar t and a column vector y, must return a column vector dydt of data type single or double that corresponds to f(t,y)."
While it may be possible in a lot of cases to actually figure out the name the function the user passed into ode45 internally uses for its first input argument, there are also cases where it wouldn't be possible. One example where it wouldn't be possible is if the function accepts varargin. The error message can't be always in sync with the code the user wrote and passed into ode45, but it can be in sync with the terminology used in the help text and documentation.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!