Using Simulink/Matlab to Solve Ordinary Differential Equations

“One Word: Simulink.”
Using Simulink/Matlab to Solve
Ordinary Differential Equations
Jake Blanchard
University of Wisconsin
2009
Introduction
Matlab offers several approaches for
solving initial value ordinary differential
equations
 Runge-Kutta solutions are common
(ode45, ode15s, etc.)
 Simulink is a Matlab add-on that allows
one to simulate a variety of engineering
systems
 We can use Simulink to solve any initial
value ODE

Process

Simulink offers a variety of components
that are assembled graphically to provide
a full system simulation
http://www.engin.umich.edu/class/ctms/simulink/model/model.htm
An Example

Consider a model for a damped, forced
oscillator
2
d x
dx

3

4
x

5
cos(
2
t
)
2
dt
dt
x(0)  0
dx
(0)  0
dt
Preparation
2
d x
dx

5
cos(
2
t
)

3

4
x
2
dt
dt
The Simulink Model
2
Clock
t->2t
cos
2t->cos2t)
5
5cos(2t)
1
s
1
s
d2x/dt 2->dx/dt
dx/dt ->x
3
dx /dt ->3dx/dt
Scope
4
x->4x
The Simulink Model
2
d x
dx

5
cos(
2
t
)

3

4
x
2
dt
dt
The Simulink Model
d 2x
dx

5
sin(
2
t
)

3
 4x
2
dt
dt
d 2x
dt 2
dx
dt
x
3
dx
dt
4x
Initial Conditions
The ICs are set in the integrator blocks
 Right click the block and open “Integrator
Parameters”
 This sets value of output variable from
the integrator block

Demo