FUNCTION REFERENCE

odeset

Create or change options for ODE solvers.

Create or change options for ODE solvers.

Syntax

options = odeset('Name', value, ...)

Syntax

options = odeset(oldopts, 'Name', value, ...)

Syntax

options = odeset(oldopts, newopts)

Syntax

options = odeset('Events', @eventFcn)

Returns a structure with one field per ODE option, 22 in MATLAB's order. An

unset option is []. Pass the structure to a solver after the initial conditions.

Read an option with options.RelTol or odeget. Names are case-insensitive and

may be abbreviated to a unique prefix. A value of [] clears that option. In

odeset(oldopts, newopts) the non-empty fields of newopts win.

ode45 and ode23 use RelTol, AbsTol, MaxStep, InitialStep, Refine, Events,

NonNegative, OutputFcn and OutputSel.

The Events option takes a function handle. Define

[value, isterminal, direction] = eventFcn(t, y) with one element per event.

The solver locates zeros bracketed by accepted steps, using its continuous

solution between the endpoints. Direction +1 selects rising crossings, -1 selects

falling crossings, and 0 or [] allows both. A nonzero isterminal stops at that

event, including during the first step. An initial zero at tspan(1) is ignored.

Several crossings of the same component can go undetected in one step. Use a

smaller MaxStep to resolve closely spaced crossings.

With [t, y, te, ye, ie], te and ie are columns, and each row of ye contains the

state at the matching event. ie contains the 1-based component indices. If

there are no events, te and ie are 0-by-1 and ye is 0-by-numel(y0). The solution

structure returned by sol = odeXX(...) with Events has sol.xe, sol.ye and sol.ie

with one column per event. The solution ends at the first terminal event.

Extra arguments after options are passed to the ODE function, Events, and any

Jacobian or Mass function the solver uses. Use [] for default options.

Example

opts = odeset('RelTol', 1e-6, 'Refine', 2); opts.Refine   % 2

Example

opts = odeset('Events', @(t,y) deal(y - 0.5, 1, -1)); [t,y,te,ye,ie] = ode45(@(t,y) -1, [0 1], 1, opts); te   % 0.5

Differences from MATLAB: ode45 and ode23 stop with an error when an option

they do not implement is set (Mass, NormControl, Stats and the stiff-solver

options). A terminal crossing in the first step stops the solve.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.