Math245 Computer Lab set #5, Fall 2008
Simulate the 2ndorder ODE by using Matlab
All existing ODE solvers (
ode45
, etc.) are primarily designed to simulate the system of the 1st order
ODEs, not the 2nd or higher order ODEs. Therefore, to simulate the 2ndorder ODEs, we need to setup
the problem by rewriting the equation into a system of 1st order ODEs. Then we can simulate the set of
1st order ODEs by using
ode45
in Matlab.
Example
Consider the initial value problem of the 2ndorder ODE
y
00
+
1
4
y
0
+ 2
y
= 0
,
y
(0) = 0
,
y
0
(0) = 2
.
(1)
(a) Simulate this initial value problem numerically for 0
≤
t
≤
30, and plot
y
(
t
) and
y
0
(
t
).
(b) Graph a phase plot
y
0
(
t
) vs
y
(
t
).
Preliminary formulation
To set up the problem, we rewrite the equation into a system of 1st order ODEs by following steps.
•
Step #1:
Let’s denote
y
=
y
1
,
y
0
=
y
2
.
(2)
Then from these equation we get
y
0
1
=
y
2
.
(3)
•
Step #2:
Let’s rewrite our 2ndorder ODE by using
y
1
and
y
2
. (i.e., we rewrite
y
00
→
y
0
2
,
y
0
→
y
2
and
y
→
y
1
in the equation.)
y
0
2
+
1
4
y
2
+ 2
y
1
= 0
.
(4)
•
Step #3:
Let’s collect 1storder ODEs ((3) and (4)) and write in the form
y
0
=
f
(
t,
y
).
y
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.
 '07
 Alexander
 Math, matlab, Boundary value problem, main program, order ODEs

Click to edit the document details