ode15s

Solve a system of stiff differential equations.

Syntax

[t,y] = ode15s(@func,tin,y0)

[t,y] = ode15s(@func,tin,y0,options)

[t,y,te,ye,ie] = ode15s(...)

Inputs

func
The system of equations to solve.
tin
The vector of times (or other domain variable) at which to report the solution. If the vector has two elements, then the solver operates in single-step mode and determines the appropriate intermediate steps.
y0
The vector of initial conditions.
options
A struct containing options settings specified via odeset.
The default relative and absolute tolerances are 1.0e-3 and 1.0e-6.
For the option to supply the analytical Jacobian, the function signature should be as follows:
function dy = jacobian(t,y)
where dy contains the derivative of the system function vector with respect to y.

Outputs

t
The times at which the solution is computed.
y
The solution matrix, with the solution at each time stored by row.
te
The times at which the 'Events' function recorded a zero value.
ye
The system function values corresponding to each te value.
ie
The index of the event that recorded each zero value.

Example

Solve the Van Der Pol oscillator. This example is not stiff, but becomes stiff for large values of mu.

function dy = VDP(t,y,mu)
  % y = [x, dx/dt]
  dy = [0, 0];
  dy(1) = y(2);
  dy(2) = mu * (1.0 - y(1)^2) * y(2) - y(1);
end

mu = 1.0; % mass
handle = @(t,y) VDP(t,y,mu);
t = [0:0.2:10]; % time vector
yi = [2, 0];
[t,y] = ode15s(handle,t,yi);
x = y(:,1)';
plot(t,x);
xlabel('time');
ylabel('amplitude');


Figure 1. ode15s figure 1

Comments

ode15s solves the system using the backward differentiation formula algorithm from the Sundials CVODE library.

To pass additional parameters to a function argument, use an anonymous function.

The odeset options and defaults are as follows.
  • RelTol: 1.0e-3
  • AbsTol: 1.0e-6
  • Jacobian: []

The 'Events' function used with the last three output arguments is specified using odeset.