selectSolver
Description
s = selectSolver(
selects a solver for the F,Name=Value)ode object
F based on the parameters specified using one or more name-value
arguments and returns the solver name. Change the ode object solver by
assigning the output of the selectSolver function to the
Solver property, for example, F.Solver =
selectSolver(F,DetectStiffness="on").
Examples
Create an ode object for the van der Pol equations with mu = 1000 using the built-in function file vdp1000.m. Specify the initial values of y' and y'' as 2 and 0, respectively.
F = ode(ODEFcn=@vdp1000,InitialValue=[2;0])
F =
ode with properties:
Problem definition
ODEFcn: @vdp1000
InitialTime: 0
InitialValue: [2×1 double]
EquationType: standard
Solver properties
AbsoluteTolerance: 1.0000e-06
RelativeTolerance: 1.0000e-03
Solver: auto
SelectedSolver: ode45
Show all properties
The automatically selected solver is ode45. Solve the ODE system over the time interval [0 3000]. Measure the time the ode45 solver takes by using tic and toc.
tic sol45 = solve(F,0,3000); toc
Elapsed time is 17.243319 seconds.
Call the selectSolver function with the DetectStiffness name-value argument to choose a solver using a stiffness detection heuristic. Also specify the IntervalLength name-value argument as 3000.
F.Solver = selectSolver(F,DetectStiffness="on",IntervalLength=3000)F =
ode with properties:
Problem definition
ODEFcn: @vdp1000
InitialTime: 0
InitialValue: [2×1 double]
Jacobian: []
EquationType: standard
Solver properties
AbsoluteTolerance: 1.0000e-06
RelativeTolerance: 1.0000e-03
Solver: ode15s
Show all properties
The selected solver is now ode15s. Solving the ODE system over the time interval [0 3000] using the ode15s solver is faster and more efficient than using the ode45 solver.
tic sol15s = solve(F,0,3000); toc
Elapsed time is 0.244035 seconds.
Input Arguments
ODE problem to solve, specified as an ode
object.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: s = selectSolver(F,DetectStiffness="on")
Stiffness detection heuristic, specified as "off" or
"on". Specify DetectStiffness as
"on" to incorporate a stiffness detection heuristic when
selecting a solver.
If you do not know if the problem is stiff but want to account for potential
stiffness, specify the DetectStiffness name-value argument as
"on". Otherwise, set the Solver property of
the ode object to:
"auto"if you do not need to account for stiffness or only need to perform basic checks. For example, if you specify a Jacobian, then"auto"will always return a stiff solver."stiff"if you know the problem is stiff."nonstiff"if you know the problem is not stiff.
Data Types: string | char
Solver time interval, specified as a positive integer. The interval length is . You can use IntervalLength to filter out
irrelevant timescales when selecting a solver.
The function ignores this argument when DetectStiffness is
"off".
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)