odeset

Specify ordinary differential equation options.

Syntax

options = odeset('option1', value1, 'option2', value2)

Inputs

optionN
The name of option N to set.
valueN
The value or string to set for option N.

Outputs

options
A struct containing the options
The available options are:
  • 'RelTol': The relative tolerance on the integrations.
  • 'Abstol': The absolute tolerance on the integrations.
  • 'MaxStep': The maximum time step in one step mode.
  • 'Jacobian': The analytical Jacobian function (only for ode15s, ode15i),
  • 'Events': The events function.

Examples

Set options to control the relative and absolute tolerances:
options = odeset('RelTol', 1.0e-3, 'AbsTol', 1.0e-6)
options = struct [
AbsTol: 1e-06
RelTol: 0.001
]
Set options to specify the analytical Jacobian function name:
options = odeset('Jacobian', @JacFunc)
options = struct [
Jacobian: JacFunc
]

Comments

The default value for RelTol is 1.0e-3. It is a scalar.

The default value for AbsTol is 1.0e-6. It can be specified as either a scalar that applies to every equation in the system, or as a vector with one element for each equation.

The default value for MaxStep is Inf.

The 'Events' function is often used to locate roots of the system of equations. The function inputs will be the same as the required system function inputs. An example follows which specifies two events to locate roots in the system of equations. function [value,isterminal,direction] = myEvent(t,y) value = [y(1) y(2)]; isterminal = [0 0]; direction = [0 0]; end The value output contains the events to be triggered when a zero occurs, such as a function root. The isterminal output is set to: 1 - if a triggered event should terminate execution. 0 - otherwise. The direction output is set to: 0 - if all zeros that occur at an event index are to be detected. 1 - if only zeros of increasing events are to be detected. -1 - if only zeros of decreasing events are to be detected. The outputs should be all scalars, or vectors with the same length.