options = odeset()
options = odeset(name, value)
options = odeset(oldOptions, name, value)
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.
options = odeset('Refine', 4, 'MaxStep', 0.5);
[t, y] = ode45(@(t,y) y, [0 1], 1, options)
f = @(t,y) -1000 * (y - cos(t)) - sin(t);
options = odeset('Jacobian', -1000, 'Stats', 'on');
[t, y] = ode15s(f, [0 0.5], 1, options)
options = odeset('NormControl', 'on');
[t, y] = ode45(@(t,y) [y(1); -2*y(2)], [0 1], [1; 1], options)
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)
options = odeset('Jacobian', -25, 'JConstant', 'on');
[t, y] = ode15s(@(t,y) -25*y, [0 0.2], 1, options)
out = @(t,y,flag) false;
options = odeset('OutputFcn', out);
[t, y] = ode45(@(t,y) y, [0 0.25 0.5], 1, options)
| Version | Description |
|---|---|
| 2.0.0 | initial version |