Why do I receive a warning about integration tolerance when using the ODE solver functions?

18 次查看(过去 30 天)
The following code:
ode23(@(t,y)1/(t-2),[0 2],5)
produces this warning:
ERROR: Warning: Failure at t=2.000000e+000.
Unable to meet integration tolerances without reducing the
step size below the smallest value allowed (7.105427e-015) at time t.

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2021-2-19
This error message indicates that the problem you are trying to solve is too stiff for the ODE solver you are trying to use, or that it includes a singularity.
In the first case, you will need to find a solver which can handle stiffer problems than the solver you are currently using. The stiff ODE solvers that are available in MATLAB are ODE15s, ODE23s, and ODE23tb.
For more information about the differences between the non-stiff and the stiff ODE solvers, please see Section 7.9 of "Numerical Computing with MATLAB". by Cleve Moler, at the following URL:
In the second case, eliminating the singularity from the region over which you are attempting to integrate should eliminate the problem. The following code produces a warning:
ode15s(@(t,y)1/(t-2),[0 2],5)
Changing the above code to:
ode15s(@(t,y)1/(t-2),[0 1.999],5)
%
avoids the singularity at t = 2.
If you are using a version of MATLAB prior to MATLAB 7.0 (R14), you will need to define the function to be integrated as an inline function or in a function file. Here an inline function is used:
O=inline('1/(t-2)','t','y')
ode15s(O,[0 1.999],5)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by