odeset
Create or update ODE options.
📝Syntax
options = odeset()
options = odeset(name, value)
options = odeset(oldOptions, name, value)
📄Description

odeset creates an options structure for ODE solvers.

Group Options Purpose
Tolerances RelTol, AbsTol, NormControl Control the adaptive error test.
Steps and output InitialStep, MaxStep, MinStep, Refine, OutputFcn, OutputSel, Stats Control public output points, output callbacks, and statistics.
Events and constraints Events, NonNegative Locate zeros and constrain selected components.
Stiff systems Mass, Jacobian, JPattern, JConstant, BDF, MaxOrder, MassSingular, MStateDependence, MvPattern Provide structural information to stiff or implicit solvers.

Common options include RelTol, AbsTol, InitialStep, MaxStep, MinStep, Refine, Stats, Events, OutputFcn, OutputSel, NonNegative, Mass, Jacobian, JPattern, JConstant, BDF, MaxOrder, MassSingular, MStateDependence, and MvPattern. Explicit step-size options must be positive.

When the time span has only two values, Refine inserts additional output points inside each accepted step. With longer time spans, requested time points define the public output points. OutputFcn is called at these refined or requested output points; returning scalar true stops integration at the current output point. Stats set to on prints step and evaluation counters. NormControl set to on uses a vector norm in the adaptive error test. Vectorized set to on allows vectorized right-hand side calls during finite-difference Jacobian construction. JPattern supplies the nonzero pattern used by stiff entries and the implicit entry when a finite-difference Jacobian is needed. JConstant set to on reuses the Jacobian inside each linearly implicit step.

💡Examples
Refined output points.
options = odeset('Refine', 4, 'MaxStep', 0.5);
[t, y] = ode45(@(t,y) y, [0 1], 1, options)
Stats and a Jacobian for a stiff entry point.
f = @(t,y) -1000 * (y - cos(t)) - sin(t);
options = odeset('Jacobian', -1000, 'Stats', 'on');
[t, y] = ode15s(f, [0 0.5], 1, options)
Vector norm control.
options = odeset('NormControl', 'on');
[t, y] = ode45(@(t,y) [y(1); -2*y(2)], [0 1], [1; 1], options)
Finite-difference Jacobian pattern.
pattern = [1 0; 0 1];
options = odeset('JPattern', pattern, 'Vectorized', 'on');
[t, y] = ode15s(@(t,y) [-10*y(1,:); -20*y(2,:)], [0 0.2], [1; 2], options)
Constant Jacobian hint.
options = odeset('Jacobian', -25, 'JConstant', 'on');
[t, y] = ode15s(@(t,y) -25*y, [0 0.2], 1, options)
Output function at requested points.
out = @(t,y,flag) false;
options = odeset('OutputFcn', out);
[t, y] = ode45(@(t,y) y, [0 0.25 0.5], 1, options)
🔗See Also
odegetode45ode15s
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub