odeset

Creates or updates the options structure used by the ODE solvers.

Category: Mathematics > Numerical Integration and Differential Equations

Syntax

options = odeset('name1', value1, 'name2', value2, ...)

Returns a structure with the given options set.

options = odeset(oldopts, 'name', value)

Copies oldopts and changes the listed options.

options = odeset(oldopts, newopts)

Merges two structures; non-empty fields of newopts win.

Description

Names are matched without regard to case and may be abbreviated when unambiguous. Options you leave out stay empty, and the solver substitutes its default.

An event function lets the integration stop, for example when a ball reaches the ground, and the event time is returned by the solver.

Input arguments

'RelTol', 'AbsTol'
Relative and absolute error tolerances. Defaults 1e-3 and 1e-6.
'MaxStep', 'InitialStep'
Bound for the step size and the size of the first step.
'Events'
Handle [value, isterminal, direction] = f(t, y) to detect zero crossings.
'Mass', 'Jacobian'
Mass matrix and Jacobian for the stiff solvers.
'NonNegative'
Indices of components that must stay nonnegative.

Output arguments

options
Structure to pass as the fourth argument of an ODE solver.

Example

Tolerances and a step limit

opts = odeset('RelTol', 1e-8, 'AbsTol', 1e-10, 'MaxStep', 0.1);
[t, y] = ode45(@(t, y) -y, [0 1], 1, opts);
fprintf('%.7f\n', y(end))
Output
0.3678794

See also

odeget ode45 ode15s bvpset ddeset