You are on page 1of 11

“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
2
 3  4 x  5 cos( 2t )
dt dt
x(0)  0
dx
(0)  0
dt
Preparation

2
d x dx
2
 5 cos( 2t )  3  4 x
dt dt
The Simulink Model
2 cos 5
Clock t->2t 2t->cos2t) 5cos(2t)

1 1
s s
d2x/dt 2->dx/dt dx/dt ->x Scope

3 4

dx /dt ->3dx/dt x->4x


The Simulink Model

2
d x dx
2
 5 cos( 2t )  3  4 x
dt dt
The Simulink Model
d 2x dx
2
 5 sin( 2t )  3  4x
dt dt
d 2x dx
x
dt 2 dt

dx
3
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

You might also like