Anda di halaman 1dari 5

Lab 2: Notes

Plotting System Response in MATLAB


MATLAB plot function can plot system response, obtained from hand-calculation. You can plot multiple responses on the
same figure using the plot function. You can also make use of the hold on function for multiple plots.

Syntax
plot(x, y), plot(x1, y1, x2, y2,…,xn, yn), hold on
plot(x, y) creates a 2-D line plot of the data in 𝑦 versus the corresponding values in 𝑥. hold on retains plots in the current
axes so that new plots added to the axes do not delete existing plots.

Example 1: Response plot


Plot the following responses for a duration of 10 seconds, then identify the stability of the system.
(a) 𝑦(𝑡) = 2𝑒 −𝑡
(b) 𝑦(𝑡) = 2𝑒 2𝑡
(c) 𝑦(𝑡) = 2𝑒 −5𝑡
(d) 𝑦(𝑡) = 5 − 2𝑒 −𝑡
(e) 𝑦(𝑡) = 𝑠𝑖𝑛2𝑡
(f) 𝑦(𝑡) = 8𝑒 −𝑡 𝑠𝑖𝑛2𝑡
(g) 𝑦(𝑡) = 𝑒 𝑡 𝑠𝑖𝑛2𝑡
(h) 𝑦(𝑡) = 𝑐𝑜𝑠2𝑡
(i) 𝑦(𝑡) = sin(2𝑡 − 𝜋/6)
(j) 𝑦(𝑡) = 𝑒 −𝑡 sin(2𝑡 − 𝜋/6)
(k) 𝑦(𝑡) = 2
(l) 𝑦(𝑡) = 2𝑒 −𝑡 + 2𝑒 −5𝑡
(m) 𝑦(𝑡) = 2𝑒 𝑡 + 2𝑒 −5𝑡

Partial Fraction Expansion with MATLAB


You can use MATLAB to easily compute the coefficients in the partial-fraction expansion. The appropriate MATLAB
function is residue. Let 𝑋(𝑠) denote the transform. In the terminology of the residue function, the expansion coefficients
are called the residues and the factors of the denominator of 𝑋(𝑠) are called the poles. The poles include the characteristic
roots of the model and any denominator roots introduced by the input function. If the order 𝑚 of the numerator of 𝑋(𝑠) is
greater than the order 𝑛 of the denominator, the transform can be represented by a polynomial 𝐾(𝑠), called the direct
(quotient) term, plus a ratio of two polynomials where the denominator degree is greater than the numerator degree.

Syntax
[r, p, k] = residue(num, den)
where num and den are arrays containing the coefficients of the numerator and denominator of 𝑋(𝑠). The output of the
function consists of the array 𝑟, which contains the residues, the array 𝑝, which contains the poles, and the array 𝐾, which
S. K. Armah, Ph.D. Page 1 of 5
contains the coefficients of the direct term 𝐾(𝑠) in polynomial form. Note that the order in which the residues are displayed
corresponds to the order in which the poles are displayed.

Example 2: Distinct poles


6𝑠 3 + 57𝑠 2 + 120𝑠 + 80
𝑋(𝑠) =
𝑠 2 + 9𝑠 + 14

[r, p, k] = residue([6, 57, 120, 80], [1, 9, 14])

OR

num = [6, 57, 120, 80];


den = [1, 9, 14];
[r, p, k] = residue(num, den)

5 4
𝑋(𝑠) = 6𝑠 + 3 + +
𝑠+7 𝑠+2
The response, using tables, is
𝑑
𝑥(𝑡) = 6 𝛿(𝑡) + 3𝛿(𝑡) + 5𝑒 −7𝑡 + 4𝑒 −2𝑡
𝑑𝑡
➢ Try
𝑠+3
(1) 𝑋(𝑠) = =
(𝑠 + 1)(𝑠 + 2)

𝑥(𝑡) =

𝑠 4 + 2𝑠 3 + 3𝑠 2 + 4𝑠 + 5
(2) 𝑋(𝑠) = =
𝑠2 + 𝑠

𝑥(𝑡) =

Example 3: Repeated poles


Consider the equation 𝑥̈ + 9𝑥̇ + 14𝑥 = 3𝑔̇ + 2𝑔, where 𝑔(𝑡) = 4𝑒 −7𝑡 . If the initial conditions are zero, the transform
of the response is
3𝑠 + 2 4 12𝑠 + 8 12𝑠 + 8
𝑋(𝑠) = ( 2 )( )= 2
= 3
𝑠 + 9𝑠 + 14 𝑠 + 7 (𝑠 + 2)(𝑠 + 7) 𝑠 + 16𝑠 2 + 77𝑠 + 98

[r, p, k] = residue([12, 8], [1, 16, 77, 98])

0.64 15.2 0.64


𝑋(𝑠) = + 2

𝑠 + 7 (𝑠 + 7) 𝑠+2

S. K. Armah, Ph.D. Page 2 of 5


The repeated poles are 𝑠 = −7, −7; one of them is a characteristic root and the other is due to the input. Note that for the
residues due to repeated poles, the residue corresponding to the highest power is displayed as the last of those residues. The
response, using tables, is
𝑥(𝑡) = 0.64𝑒 −7𝑡 + 15.2𝑡𝑒 −7𝑡 − 0.64𝑒 −2𝑡

➢ Try
𝑠 2 + 2𝑠 + 3
(1) 𝑋(𝑠) = =
(𝑠 + 1)3

𝑥(𝑡) =

5(𝑠 + 2)
(2) 𝑋(𝑠) = =
𝑠 2 (𝑠+ 1)(𝑠 + 3)

𝑥(𝑡) =

Example 4: Complex poles


Complex poles are handled as follows. Consider the equation 𝑥̈ + 6𝑥̇ + 34𝑥 = 4𝑔̇ + 𝑔, where 𝑔(𝑡) is a unit-step function
and the initial conditions are zero. The transform of the response is
4𝑠 + 1 4𝑠 + 1
𝑋(𝑠) = = 3
(𝑠 2 + 6𝑠 + 34)𝑠 𝑠 + 6𝑠 2 + 34𝑠

[r, p, k] = residue([4, 1], [1, 6, 34, 0])

−0.0147 − 0.3912𝑗 −0.0147 + 0.3912𝑗 0.0294


𝑋(𝑠) = + +
𝑠 + 3 − 5𝑗 𝑠 + 3 + 5𝑗 𝑠
The response, using tables, is
𝑥(𝑡) = (−0.0147 − 0.3912𝑗)𝑒 (−3+5𝑗)𝑡 + (−0.0147 + 0.3912𝑗)𝑒 (−3−5𝑗)𝑡 + 0.0294
This form is not very useful because of its complex coefficients, but we can convert it to a more useful form by noting that
the first two terms in the expansion have a form, which corresponds to the time function
(𝐶 + 𝐷𝑗)𝑒 (−𝑎 + 𝑏𝑗)𝑡 + (𝐶 − 𝐷𝑗)𝑒 (−𝑎 − 𝑏𝑗)𝑡
Using Euler’s identities: 𝑒 ±𝑗𝑏𝑡 = cos 𝑏𝑡 ± 𝑗sin 𝑏𝑡, the previous form can be written as
2𝑒 −𝑎𝑡 (𝐶cos𝑏𝑡 − 𝐷sin𝑏𝑡)
Using this identity, we can write the response
𝑥(𝑡) = 2𝑒 −3𝑡 (−0.0147cos5𝑡 + 0.3912sin5𝑡) + 0.0294

S. K. Armah, Ph.D. Page 3 of 5


➢ Try

2𝑠 + 12
𝑋(𝑠) = =
𝑠2 + 2𝑠 + 5

𝑥(𝑡) =

Note, the command

[num, den] = residue(r, p, k)


converts the partial-fraction expansion back to the polynomial ratio 𝐵(𝑠)/𝐴(𝑠).

Laplace Transformation in MATLAB


Laplace transform, and inverse Laplace transform can be carried out in MATLAB, using the laplace and ilaplace functions,
respectively.

Syntax
laplace (f) and ilaplace(F)
laplace(f) returns the Laplace Transform of 𝑓. By default, the independent variable is 𝑡 and transformation variable is 𝑠.
ilaplace(F) returns the Inverse Laplace Transform of 𝐹. By default, the independent variable is 𝑠 and the transformation
variable is 𝑡. For example,

𝑓(𝑡) = 5𝑒 −2𝑡

syms t

f = 5*exp(-2*t);
laplace(f)

OR

laplace(5*exp(-2*t))

which gives
5
ans =
𝑠+2
Similarly, given

7
𝐹(𝑠) = 2
(𝑠 − 3)
S. K. Armah, Ph.D. Page 4 of 5
syms s

F = 7/(s – 3)^2;
ilaplace(F)

OR

ilaplace(7/(s – 3)^2)

which gives
ans = 7𝑡𝑒 3𝑡

➢ Try

(1) ℒ[2𝑠𝑖𝑛3𝑡 + 𝛿(𝑡 − 1) + 𝑡 5 ] =

(2) ℒ [𝑐𝑜𝑠2𝑡 𝑒 2𝑡 ] =
1 0

𝑑𝑓
(3) ℒ [ ]=
𝑑𝑡

−1
𝑒 −2𝑠
(4) ℒ [ 2 ]=
𝑠 +1

𝑠 0
(5) ℒ −1 [ ]=
1 1/𝑠 2

S. K. Armah, Ph.D. Page 5 of 5

Anda mungkin juga menyukai