You are on page 1of 8

Experiment 4: Student’s Manual

American International University- Bangladesh


Department of Electrical and Electronic Engineering
EEE 4101: Control Systems Lab

Title: Performing Mathematical Operation and Performance Analysis in MATLAB.


Abstract:
This experiment shows -
1. To understand how to perform mathematical operations like partial fraction
expansion, simplification, pole-zero determination, Laplace transform, inverse
Laplace transform, state-space model generation etc.
2. To understand how to analyze performance of second order systems.

Students will first learn about the different MATLAB functions for different mathematical
operations. After that they will run MATLAB programs to solve some particular problems.
They will compare the results of MATLAB and SIMULINK later.

Introduction:
MATLAB allows designers to perform complicated mathematical calculations in fast and
efficient manner. Partial fraction expansion, simplification, pole-zero determination, Laplace
transform, inverse Laplace transform, state-space model generation are some of the
mathematical operation that can be very easily performed in MATLAB. Performing Laplace
and inverse Laplace transforms are mathematical methods. They are widely used in
control systems. After performing Laplace transforms, different mathematical operations can
be applied to them. Students will learn to implement them using MATLAB.

To view the step response of a particular system for a particular transfer function, unit
step function is given as an input. The output is then the step response.

Theory and Methodology:


MATLAB Functions:

o ROW matrix/ row vector is defined to express Laplace transform expressions.


Variable coefficients are defined in left to right descending power of ‘s’ format. For
example, deng=[500 0 0]
o SERIES: Series is the interconnection of the two Linear Time Invariant models.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 1


SYS = SERIES(SYS1,SYS2,OUTPUTS1,INPUTS2) connects two LTI models. SYS1
and SYS2 are in series such that the outputs of SYS1 specified by OUTPUTS1 are
connected to the inputs of SYS2 specified by INPUTS2. The vectors OUTPUTS1
and INPUTS2 contain indices into the outputs and inputs of SYS1 and SYS2,
respectively. The resulting LTI model SYS maps u1 to y2.

If OUTPUTS1 and INPUTS2 are omitted, SERIES connects SYS1 and SYS2 in cascade
and returns
SYS = SYS2 * SYS1

SYS = SERIES(SYS1,SYS2,'name') connects SYS1 and SYS2 by matching I/O names.


The output names of SYS1 and input names of SYS2 should be fully specified.

If SYS1 and SYS2 are arrays of LTI models, SERIES returns an LTI array SYS of the
same size where SYS(:,:,k) = SERIES(SYS1(:,:,k),SYS2(:,:,k),OUTPUTS1,INPUTS2) .

o PRINTSYS: Print system in pretty format and is used to print state space systems with
labels to the right and above the system matrices or to print transfer functions as a ratio of
two polynomials.
PRINTSYS(NUM,DEN,'s') or PRINTSYS(NUM,DEN,'z') prints the transfer function as a
ratio of two polynomials in the transform variable 's' or 'z'.

o FEEDBACK: Feedback connection of two LTI models.


SYS = FEEDBACK(SYS1,SYS2) computes an LTI model SYS for the closed-loop
feedback system

Negative feedback is assumed and the resulting system SYS maps u to y. To apply
positive feedback, use the syntax:
SYS = FEEDBACK(SYS1,SYS2,+1).

o STEP: Step response of LTI models


[Y,T] = STEP(SYS) returns the output response Y and the time vector T used for
simulation. No plot is drawn on the screen.
If SYS has NY outputs and NU inputs, and LT = length(T), Y is an array of size [LT NY
NU] where Y(:,:,j) gives the step response of the j-th input channel.
[Y,T,X] = STEP(SYS) also returns, for a state-space model SYS, the state trajectory X, a
LT-by-NX-by-NU array if SYS has NX states.

o POLY: Convert roots to polynomial.


POLY(A), when A is an N by N matrix, is a row vector with N+1 elements which are the
coefficients of the characteristic polynomial, DET(lambda*EYE(SIZE(A)) - A) .

o RESIDUE: Partial-fraction expansion (residues).


[R,P,K] = RESIDUE(B,A) finds the residues, poles and direct term of a partial fraction
expansion of the ratio of two polynomials B(s)/A(s).

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 2


If there are no multiple roots,

B(s) R(1) R(2) R(n)


---- = -------- + -------- + ... + -------- + K(s)
A(s) s - P(1) s - P(2) s - P(n)

Vectors B and A specify the coefficients of the numerator and denominator polynomials in
descending powers of s. The residues are returned in the column vector R, the pole
locations in column vector P, and the direct terms in row vector K. The number of poles is
n = length(A)-1 = length(R) = length(P). The direct term coefficient vector is empty if
length(B) < length(A), otherwise length(K) = length(B)-length(A)+1.

o TF: Creation of transfer functions or conversion to transfer function.


Creation:
SYS = TF(NUM,DEN) creates a continuous-time transfer function SYS with numerator(s)
NUM and denominator(s) DEN. The output SYS is a TF object.

o ZPK Create zero-pole-gain models or convert to zero-pole-gain format.


Creation:
SYS = ZPK(Z,P,K) creates a continuous-time zero-pole-gain (ZPK) model SYS with zeros
Z, poles P, and gains K. The output SYS is a ZPK object.

o The sym command creates symbolic variables and expressions. For example, the
commands x = sym('x'); a = sym('alpha'); create a symbolic variable x with the value x
assigned to it in the MATLAB workspace and a symbolic variable ‘a’ with the value alpha
assigned to it. An alternate way to create a symbolic object is to use the syms command:

o pretty(X) prints symbolic output of X in a format that resembles typeset mathematics.

o laplace(f) computes the Laplace transform of f.

o ilaplace(F) computes the Inverse Laplace transform of F.

o SIMPLIFY Simplify representation of Uncertain objects

B = SIMPLIFY(A) performs model-reduction-like techniques to detect and eliminate


redundant copies of uncertain elements. Depending on the result, the CLASS of B may be
lower than A. The AutoSimplify property of each uncertain element in A determines what
reduction methods are used. After reduction, any uncertain element which does not
actually affect the result is deleted from the representation.

o TF2SS: Transfer function to state-space conversion.


[A,B,C,D] = TF2SS(NUM,DEN) calculates the state-space representation of the system:

x = Ax + B

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 3


y = Cx + Du

o Time limit is selected using t=[ lower limit : interval : upper limit]. For example,
t = [ 0:0.1:20]

Mathematical problems for performance analysis in MATLAB:


Solve the following problems in MATLAB:

1. Write down two transfer functions (as if after performing Laplace transform on them) that
are defined as follows:
𝑛𝑢𝑚𝑔 1 𝑛𝑢𝑚𝑐 𝑆+1
= and =
𝑑𝑒𝑛𝑔 500𝑆 2 𝑑𝑒𝑛𝑐 𝑆+2

Then use the MATLAB function “series” and apply a negative feedback. Both
expressions should be viewed using the MATLAB function “printsys”.

2. Write down the following transfer function (after performing Laplace transform on it):

5400
𝐺 (𝑆 ) =
2𝑆 2 + 2.5𝑆 + 5402

Now using the MATLAB function “step” a unit step function is given as an input for the
wheel velocity versus time response and the output response is seen for certain time limit
defined as “t”.

3. Using the MATLAB function “poly”, convert ‘deny’ to polynomial from the roots value given in
the program. Then using the MATLAB function “residue”, do partial fraction expansion to the
function defined by ‘numy’ and ‘deny’.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 4


Program segment 3 output in the MATLAB command window:
deny =
1 12 32 0

r=
1
-2
1

p=
-8
-4
0

k=
[]

4. Write down the following transfer function (as if after performing Laplace transform on
it) first as row vector.
150𝑆 2 + 300𝑆 + 1050
𝐺 (𝑆 ) =
𝑆 2 + 5.4𝑆

Then using the MATLAB function “tf”, show an actual mathematical expression of the
transfer function in the output.

5. Define the transfer function (as if after performing Laplace transform on it) as two
separate row vectors for numerator and denominator. Define the gain "k" as a variable.
Then using the MATLAB function “zpk”, convert the transfer function to zero pole gain
format.

20(𝑆 + 2)(𝑆 + 4)
𝐺 (𝑆 ) =
(𝑆 + 7)(𝑆 + 8)(𝑆 + 9)

6. Define a symbolic variable 's' and then define Laplace transformed functions 'F1' and
‘F2’ using 's' for the following equations. After that, apply inverse Laplace transform to
'F1' and ‘F2’ using the MATLAB function “ilaplace”. Show all the equations in standard
mathematical format using the MATLAB function “pretty”.

2 3
i) 𝐹1 = (𝑆+1)(𝑆+2)2
and ii) 𝐹2 = 𝑆 (𝑆 2+2𝑆+5)

7. Define symbolic variable 't' and then define an inverse Laplace transform function 'f'.
After that, apply Laplace transform to 'f' using the MATLAB function “laplace”. Show
all the equations in standard mathematical format using the MATLAB function “pretty”
and do further simplification using the MATLAB function "simplify".

𝑓 = 2𝑒 −𝑡 − 2𝑡𝑒 −2𝑡 −2𝑒 −2𝑡


𝜔𝑛2
𝐺(𝑆) =
𝑆 2 + 2ζωn S + 𝜔𝑛2

8. Define a transfer function (as if after performing Laplace transform on it) as two separate
row vectors for numerator and denominator. Then convert the transfer function to its
equivalent state space representation using the MATLAB function “tf2ss”.
© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 5
Program segment 8 output in the MATLAB command window:
a=
x1 x2 x3
x1 -8.00000 -18.00000 -6.00000
x2 1.00000 0 0
x3 0 1.00000 0

b=
u1
x1 1.00000
x2 0
x3 0

c=
x1 x2 x3
y1 2.00000 8.00000 6.00000

d=
u1
y1 0

9. From exercise # 8, several state space representation variables are defined. Convert them
to transfer function using mathematical equation.

10. Perform step responses of the second order system for different values of zeta (ζ). (The
same problem will be done with SIMULINK later).

The general form of second order equation:

ω2n
G (S) =
S 2 + 2ζωn S + ω2n

Consider, ωn =1 and vary the value of ζ.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 6


Program segment 10 output in the MATLAB command window:
2

1.8

1.6

1.4

1.2
wheel velocity

0.8

0.6

0.4

0.2

0
0 0.5 1 1.5 2 2.5 3
time [ s ec]

step response of 2nd order systems for various values of zeta


2

1.8

1.6

1.4

1.2

1
y(t)

0.8

0.6

0.4

0.2

0
0 2 4 6 8 10 12 14 16 18 20
W nt

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 7


Pre-Lab Homework:
Students should study on the following questions and prepare a short report on it before the
start of the lab experiment-
1. Laplace transform and its mathematical manipulations,
2. Basic idea and block diagram of control systems,
3. Basic idea and block diagram of open loop control system,
4. Basic idea and block diagram of close loop control system.

Apparatus:

1) Computer
2) MATLAB Software Installed in the
Computer

Precautions:
Students should take the following precautions while conducting the experiment -
1. Check the PC if it is working; otherwise inform lab instructor,
2. Be careful while handling the power supply buttons of computers and to keep
them off when they are not needed,
3. Check if MATLAB is working correctly and beware of typing mistakes.

Experimental Procedure:
1. Run the MATLAB code and identify the outputs.
2. Step responses should be checked and compared by zooming over the overshoot portion
and the time it takes to reach the steady state value.

Simulation and Measurement:


Compare the simulation results with your experimental data/ wave shapes and comment on the
differences (if any).

Questions for report writing:


1. Write a report on this experiment.

Discussion and Conclusion:


If the code syntaxes are all correct then the practically obtained data should exactly match the
one obtained through codes. Which will, in turn validate the process.

Reference(s):
Norman S. Nise, “Control Systems Engineering”, available Edition, John Wiley & Sons Inc.

© Dept. of EEE, Faculty of Engineering, American International University-Bangladesh (AIUB) 8

You might also like