ode23
Low-order Runge-Kutta solver for nonstiff differential equations.
Category: Mathematics > Numerical Integration and Differential Equations
Syntax
[t, y] = ode23(odefun, tspan, y0)
Integrates y' = odefun(t, y) over tspan from y0.
[t, y] = ode23(odefun, tspan, y0, options)
Also applies options from odeset.
sol = ode23(___)
Returns a structure for use with deval.
Description
ode23 pairs a second-order and a third-order Runge-Kutta formula to estimate the error and adapt the step. It is cheaper per step than ode45 but needs more steps for a given accuracy, so it is the better choice for crude tolerances or for mildly stiff problems.
When tspan has only two entries, the solver returns the points it chose; with more entries, it returns the solution at exactly those times.
Input arguments
odefun- Handle
dydt = odefun(t, y)returning a column vector. tspan[t0 tf], or a longer vector of times at which to report the solution.y0- Vector of initial values.
options- Structure from
odeset.
Output arguments
t- Column vector of time points.
y- Array with one row per time and one column per component.
Example
Exponential decay
[t, y] = ode23(@(t, y) -y, [0 1], 1);
fprintf('%.4f %.4f\n', y(end), exp(-1))
Output
0.3679 0.3679