Main Content


Extract ODE option values



v = odeget(options,'Name') extracts the value of the named option from options, which is a structure containing option values. Use odeset to create or update the options structure.


v = odeget(options,'Name',default) returns the value v = default if the named option does not have a value specified in options.


collapse all

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,...
options = struct with fields:
              AbsTol: 1.0000e-05
                 BDF: []
              Events: []
         InitialStep: []
            Jacobian: []
           JConstant: []
            JPattern: []
                Mass: @(t)[t,0;0,-t]
        MassSingular: 'no'
            MaxOrder: []
             MaxStep: []
         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:

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

collapse all

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

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'

  • Event functions — 'Events'

  • Jacobian matrix — 'Jacobian', 'JPattern', 'Vectorized'

  • Mass matrix — 'Mass', 'MStateDependence', 'MvPattern', 'MassSingular', 'InitialSlope'

  • Algorithm options for ode15s and ode15i'MaxOrder', 'BDF'

Example: v = odeget(options,'AbsTol')

Data Types: char | string

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: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | struct | table | cell | function_handle | categorical

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced before R2006a