This preview shows pages 1–2. Sign up to view the full content.
Math245 Computer Lab set #3, Fall 2008
Solve the 1st order ODE by using Matlab
We consider the 1st order ODE in the form
dy
dt
=
f
(
t,y
)
,
with initial condition
y
(0) =
y
0
. To obtain the numerical solution to this initial value problem, we will
use ODE solver
ode45
(RungeKutta 45th order method) in Matlab package. The simplest use of
ode45
is in the following form:
[ t, y ] = ode45(@odefun, tspan, initvalue);
@odefun
: (IN) information of Matlab function ﬁle where
f
(
t,y
) is deﬁned.
tspan
: (IN) interval of independent variable
t
, e.g.,
[t0 tend]
(vector with two elements).
initvalue
: (IN) initial value.
t
: (OUT) time (independent variable) vector.
y
: (OUT) solution vector which corresponds to the time vector
t
.
The output variables (
t
and
y
) are in the row vector form. The structure of these vectors are described
as follows.
t
=
t
0
t
1
t
2
.
.
.
t
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 11/08/2009 for the course MATH 245 at USC.
 '07
 Alexander
 Math, matlab

Click to edit the document details