19
Example 2: Ordinary Differential Equations (ODE)
The general rule for solving differential equations is to write the equation in terms of the highest
differential. For example, consider the general second order equation below.
𝑦⃛ + 𝑎𝑦̈ + 𝑏𝑦̇ + 𝑐𝑦 = 𝑓(𝑡)
(1)
𝑦⃛ = 𝑓(𝑡) − 𝑎𝑦̈ − 𝑏𝑦̇ − 𝑐𝑦
You then use integrators to obtain lower terms:
The right hand side of the equations is formed by feeding back these terms to form the expression
required.
Notice that the model contains no differentiators, even though we are modelling a differential
equation. Models with differentiators tend to produce a lot of noise, so are avoided if possible.
The next example is not linear or time invariant:
𝑦̈ = 𝑦̇
2
− 𝑡𝑦
(2)
20
Example 3: Simultaneous Ordinary Differential Equations
Of course Simulink is not limited to equations in one variable.
Consider the simultaneous equation below:
𝑥̈ = 𝑝𝑥̇ + 𝑎𝑥 + 𝑏𝑦
𝑦̈ = 𝑞𝑦̇ + 𝑐𝑥 + 𝑑𝑦
(3)
This can be simplified by using matrices:
[
𝑥̈
𝑦̈] = [
𝑝𝑥̇
𝑞𝑦̇] + [
𝑎 𝑏
𝑐 𝑑
] [
𝑥
𝑦]
(4)
21
Example 4: Linear Systems
Many systems can be modelled by linear, time invariant (LTI) differential equations, such as
equation 5 below.
𝑎
3
y⃛ + 𝑎
2
𝑦̈ + 𝑎
1
𝑦̇ + 𝑎
0
𝑦 = 𝑏
2
𝑥̈ + 𝑏
1
𝑥̇ + 𝑏
0
𝑥
(5)
where y is the output and x the input.
LTI systems can be represented by a transfer function:
𝐻(𝑠) =
𝑌(𝑠)
𝑋(𝑠)
=
𝑏
2
𝑠
2
+ 𝑏
1
𝑠 + 𝑏
0
𝑎
3
𝑠
3
+ 𝑎
2
𝑠
2
+ 𝑎
1
𝑠 + 𝑎
0
𝐻(𝑗𝜔) =
𝑏
2
(𝑗𝜔)
2
+ 𝑗𝜔𝑏
1
+ 𝑏
0
𝑎
3
(𝑗𝜔)
3
+ 𝑎
2
(𝑗𝜔)
2
+ 𝑗𝜔𝑎
1
+ 𝑎
0
It is the convention in MATLAB to represent polynomial expressions with row vectors of the
coefficients. So the numerator of the above transfer function is represented by [b
2
b
1
b
0
] and the
denominator by [a
3
a
2
a
1
a
0
]. Entering these two vectors to the appropriate block parameters of a
transfer function block will produce the following block:
LTI transfer functions are used extensively in electronics to represent idealized electronic circuits.
Take for example this circuit and its transfer function representation below:
𝐻(𝑠) =
𝑉𝑜𝑢𝑡(𝑠)
𝑉𝑖𝑛(𝑠)
=
𝑠𝜔
𝑛
𝑠
2
+ 3s𝜔
𝑛
+ 𝜔
𝑛
2
(6)
The following model can be used to observe the behaviour in Simulink:
In the Transfer Function block parameters values are set with
wn
being a predefined variable in the
MATLAB workspace: numerator =
[wn 0]
and denominator =
[1 3*wn wn^2]
|