odeget
Extract ODE option values
Description
Examples
Extract ODE Option Values
Create an options structure using odeset
that contains several values for different options.
M = @(t) [t 0; 0 -t]; options = odeset(RelTol=1e-4,AbsTol=1e-5,OutputFcn=@odephas2,... Mass=M,MassSingular="no",MStateDependence="none")
options = struct with fields:
AbsTol: 1.0000e-05
BDF: []
Events: []
InitialStep: []
Jacobian: []
JConstant: []
JPattern: []
Mass: @(t)[t,0;0,-t]
MassSingular: 'no'
MaxOrder: []
MaxStep: []
MinStep: []
NonNegative: []
NormControl: []
OutputFcn: @odephas2
OutputSel: []
Refine: []
RelTol: 1.0000e-04
Stats: []
Vectorized: []
MStateDependence: 'none'
MvPattern: []
InitialSlope: []
Use odeget
to extract the value of the OutputFcn
field from the options structure.
v = odeget(options,"OutputFcn")
v = function_handle with value:
@odephas2
Now extract the value of the Refine
field. Since this field is not set, odeget
returns an empty matrix []
.
v = odeget(options,"Refine")
v = []
You can specify a third input to odeget
to change the default return value. This ensures that v
is never empty.
v = odeget(options,Refine=1)
v = 1
Input Arguments
options
— Options structure
structure
Options structure. Use odeset
to
create or modify the options structure.
Example: options = odeset(RelTol=1e-4,AbsTol=1e-5)
returns an options
structure with values specified for the relative and absolute error
tolerances.
Data Types: struct
Name
— Option name
any valid option from odeset
Option name, specified as any valid option accepted by odeset
:
Error control —
"AbsTol"
,"RelTol"
,"NormControl"
Output control —
"NonNegative"
,"OutputFcn"
,"OutputSel"
,"Refine"
,"Stats"
Solver steps —
"InitialStep"
,"MaxStep"
,"MinStep"
Event functions —
"Events"
Jacobian matrix —
"Jacobian"
,"JPattern"
,"Vectorized"
Mass matrix —
"Mass"
,"MStateDependence"
,"MvPattern"
,"MassSingular"
,"InitialSlope"
Algorithm options for
ode15s
andode15i
—"MaxOrder"
,"BDF"
Example: v = odeget(options,"AbsTol")
Data Types: char
| string
default
— Default return value
any MATLAB object
Default return value, specified as any valid MATLAB object.
Example: v = odeget(options,AbsTol=1e-6)
returns 1e-6
if
options
does not have a value set for
AbsTol
.
Data Types: s
| single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| char
| struct
| table
| cell
| function_handle
| categorical
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
The
name
argument must be constant.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
Version History
Introduced before R2006a
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)