[t, y]= odexxx(odefunc, tf, y0), or
[t, y]= odexxx(odefunc, [t0 tf], y0)
The input parameters for an ODE solver are as follows.
odefunc: The name of the user-defined function that evaluates the slope f ðt; yÞ,
entered within single quotation marks. For a coupled ODE problem,
this ODE function shou ld output a column vector whose elements are
the first derivatives of the dependent variables, i.e. the right-hand side
of the ODE equations.
[t0 tf]: The beginning and ending tim e points of the time interval.
y0: The value of the dependent variable(s) at time 0. If there is more than
one dependent variable, y0 should be supplied as a column vector,
otherwise y0 is a scalar. The order in which the initial values of the
variables should be listed must correspond to the order in which their
slopes are calculated in the ODE function odefunc.
The output variables are as follows.
t: A column vector of the time points at which the numerical solution has been
calculated. The time points will not be uniformly spaced since the time step is
optimized during the integration. If you require a solution at certain time points
only, you should specify a vector containing specific time points in place of the
time interval [t0, tf], e.g.
[t, y]= odexxx(odefunc, [0:2:10], y0)
The numerical solution y will be output at these six time points, although higher
resolution may be used during integration.
y: For a single ODE problem, this is a column vector containing the solution at
time points recorded in vector t. For a coupled ODE problem, this is a matrix with
each column representing a different dependent variable and each row repres enting a
different time point that corresponds to the same row of t.
The optimal step size is chosen such that the local truncation error ekðÞat step k,
estimated by the algorithm, meets the following tolerance criteria:
e(k) ≤ max(RelTol * |y(k)|, AbsTol)
The default value for the relative tolerance RelTol is 10
−3
. The default value for
the absolute tolerance AbsTol is 1 × 10
−6
.For y
jj
4
10
3
the relative tolerance will set
the tolerance limit. For y
jj
5
10
3
, the absolute tolerance will control the error. For
y
jj
1, it is recommended that you change the default value of AbsTol accordingly.
Sometimes you may want to suggest an initial step size or specify the maximum
step size (default is 0:1 t
f
t
0
ðÞ) allowed during integration. To change the default
settings of the ODE solver you must create an options structure and pass that
structure along with other parameters to the odexxx function. A structure is a data
type that is somewhat like an array except that it can contain different types of data
such as character arrays, numbers, and matrices each stored in a separate field. Each
field of a structure is given a name. If the name of the structure is Options, then
RelTol is one field and its contents can be accessed by typing Options.RelTol.
To create an options structure, you will need to use the function odese t. The
syntax for odeset is
446
Numerical integration of ODEs