You are on page 1of 3

EEET2493 M0DERN CONTROL SYSTEMS LAB.

REPORT 4, November 2020

Performing Mathematical Operation and Performance


Analysis in MATLAB
Ghosh Saikat(13-23829-1)
Group Member
Arittra Biswas(17-35781-3), Minhazur Rahman(18-37204-1), Md. Rakibul Hasan(18-38877-3), Zayed Zaman(19-39904-1)

Abstract—Different types of mathematical operations like partial 3.PRINTSYS: Print system in pretty format and was used to print
fraction expansion, simplification, pole-zero determination, state space systems with labels to the right and above the system
Laplace transform, inverse Laplace transform, state-space model matrices or to print transfer functions as a ratio of two polynomials.
generation etc are performed in this experiment. PRINTSYS(NUM,DEN,'s') or PRINTSYS(NUM,DEN,'z') prints the
transfer function as a ratio of two polynomials in the transform
Keywords- simplification, determination, laplace transform, inverse variable 's' or 'z'
Laplace transform. .
4.FEEDBACK: Feedback connection of two LTI models.
I. Introduction
SYS = FEEDBACK(SYS1,SYS2) computes an LTI model SYS for
Designers are allowed to perform complicated mathematical the closed-loop feedback system
calculations in fast and efficient manner in MATLAB. 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.
Negative feedback is assumed and the resulting system SYS maps u
II. Theory and Methodology to y. To apply positive feedback, use the syntax:
SYS = FEEDBACK(SYS1,SYS2,+1).
1. ROW matrix/ row vector was defined to express Laplace transform
expressions. Variable coefficients were defined in left to right 5.STEP: Step response of LTI models
descending power of ‘s’ format. For example, deng=[500 0 0] [Y,T] = STEP(SYS) returns the output response Y and the time
vector T used for simulation. No plot is drawn on the screen.
2. SERIES: Series is the interconnection of the two Linear Time If SYS has NY outputs and NU inputs, and LT = length(T), Y is an
Invariant models. 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.

6.POLY: Convert roots to polynomial.


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

7.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).If there
are no multiple roots,
SYS = SERIES(SYS1,SYS2,OUTPUTS1,INPUTS2) connects two
B(s) R(1) R(2) R(n)
LTI models. SYS1 and SYS2 are in series such that the outputs of
SYS1 specified by OUTPUTS1 are connected to the inputs of SYS2 ---- = -------- + -------- + ... + -------- + K(s)
specified by INPUTS2. The vectors OUTPUTS1 and INPUTS2 A(s) s - P(1) s - P(2) s - P(n)
contain indices into the outputs and inputs of SYS1 and SYS2, Vectors B and A specify the coefficients of the numerator and
respectively. The resulting LTI model SYS maps u1 to y2. denominator polynomials in descending powers of s. The residues
If OUTPUTS1 and INPUTS2 are omitted, SERIES connects SYS1 were returned in the column vector R, the pollocations in column
and SYS2 in cascade and returns vector P, and the direct terms in row vector K. The number of poles
SYS = SYS2 * SYS1 is n=length(A)-1 = length(R) = length(P). The direct term coefficient
SYS = SERIES(SYS1,SYS2,'name') connects SYS1 and SYS2 by vector is empty if length(B) < length(A), otherwise length(K) =
matching I/O names. The output names of SYS1 and input names of length(B)-length(A)+1.
SYS2 should be fully specified.
8.TF: Creation of transfer functions or conversion to transfer
If SYS1 and SYS2 are arrays of LTI models, SERIES returns an LTI
function. Creation:
array SYS of the same size where SYS(:,:,k) =
SERIES(SYS1(:,:,k),SYS2(:,:,k),OUTPUTS1,INPUTS2) .
SYS = TF(NUM,DEN) creates a continuous-time transfer function Continuous-time transfer function.
SYS with numerator(s) NUM and denominator(s) DEN. The output
SYS is a TF object. Code2:
9.ZPK Create zero-pole-gain models or convert to zero-pole-gain %transfer function
format. num=[5400]
Creation: den=[2 2.5 5402]
SYS = ZPK(Z,P,K) creates a continuous-time zero-pole-gain (ZPK) tf(num,den
model SYS with zeros Z, poles P, and gains K. The output SYS is a
ZPK object. [c,x,t]=step(num,den)
Plot(t,c)
10.The sym command creates symbolic variables and expressions. ans =
For example, the commands x = sym('x'); a = sym('alpha'); create a 5400
symbolic variable x with the value x assigned to it in the MATLAB -------------------
workspace and a symbolic variable ‘a’ with the value alpha assigned 2 s^2 + 2.5 s + 5402
to it. An alternate way to create a symbolic object is to use the syms
command: Code:4
11.pretty(X) prints symbolic output of X in a format that resembles %transfer function
typeset mathematics. num=150*[1 2 7]
12.laplace(f) computes the Laplace transform of f. den=[1 5.4 0]
13.ilaplace(F) computes the Inverse Laplace transform of F. tf(num,den)
14.SIMPLIFY Simplify representation of Uncertain objects ans =
B = SIMPLIFY(A) performs model-reduction-like techniques to 150 s^2 + 300 s + 1050
detect and eliminate redundant copies of uncertain elements. ----------------------
Depending on the result, the CLASS of B may be lower than A. The s^2 + 5.4 s
AutoSimplify property of each uncertain element in A determines
what reduction methods are used. After reduction, any uncertain Code:5 %zeros,poles,gain
element which does not actually affect the result is deleted from the zpk([-2,-4],[-7,-8,-9],20)
representation.
ans =
15.TF2SS: Transfer function to state-space conversion. 20 (s+2) (s+4)
[A,B,C,D] = TF2SS(NUM,DEN) calculates the state-space -----------------
representation of the system: (s+7) (s+8) (s+9)
x= Ax + B
x= Cx + Du Code:6(i)
16. Time limit is selected using t=[ lower limit : interval : upper %inverse laplace
limit]. For example, t = [ 0:0.1:20] syms s;
F1=2/[(s+1)*(s+2)^2]
III. Apparatus pretty(F1)
1. Computer
f=ilaplace(F1)
2. MATLAB Software Installed in the Computer pretty(f)

IV. Experimental Procedure: ans:


1. MATLAB code was run and the output was identified.. F1 =
2. Step responses was checked and compared by zooming over the 2/((s + 1)*(s + 2)^2)
overshoot portion and the time it takes to reach the steady state value 2
V. MATLAB Calculation ----------------
2
Code1: (s + 1) (s + 2)

f=
%Transfer functionnum=[1]
2*exp(-t) - 2*exp(-2*t) - 2*t*exp(-2*t)
2 exp(-t) - exp(-2 t) 2 - t exp(-2 t) 2
den=[500 0 0]
Code:6(ii)
tf(num,den) syms s;
F2=3/[s*(s^2+2*s+5)]
pretty(F2)
result: f=ilaplace(F2)
pretty(f)
num = 1 ans:
F2 =
den = 500 0 0 3/(s*(s^2 + 2*s + 5))
3
----------------
ans = 2
s (s + 2 s + 5)
1 f=
3/5 - (3*exp(-t)*(cos(2*t) + sin(2*t)/2))/5
------- / sin(2 t) \
exp(-t) | cos(2 t) + -------- | 3
3\2/
500 s^2
- - --------------------------------- [2] AIUB Lab manual
55

Code:7
%laplace
syms t;
f=2*exp(-t)-2*t*exp(-2*t)-2*exp(-2*t)
pretty(f)
F=laplace(f)
pretty(F)
simplify(F)
ans:
f=
2*exp(-t) - 2*exp(-2*t) - 2*t*exp(-2*t)
2 exp(-t) - exp(-2 t) 2 - t exp(-2 t) 2

F=
2/(s + 1) - 2/(s + 2) - 2/(s + 2)^2
222
----- - ----- - --------
s+1s+22
(s + 2)
ans =
2/((s + 1)*(s + 2)^2)

Code:8
%converting from tf to ss
num=[2 8 6]
den=[1 8 18 6]
[A,B,C,D]=tf2ss(num,den)
ans:
num = 2 8 6
den = 1 8 18 6
A = -8 -18 -6
100
010
B=1
0
0
C=286
D=0

Code:9 %converting from s.s to tf


A=[-8 -18 -6;1 0 0;0 1 0]
B=[1;0;0]
C=[2 8 6]
D=0
T=ss2tf(A,B,C,D)
tf(T)

VI. Result
T =0 2 8 6
ans =
From input 1 to output: 0
From input 2 to output:2
From input 3 to output: 8
From input 4 to output:6
Static gain.

VII. Discussion
Matlab syntaxes were used correctly. All Matlab functions were
used correctly and checked.

VIII. Conclusion
All Matlab output data were exactly same as practically obtained
data.

Reference(s)
[1]https://www.mathworks.com/help/matlab/ref/ss2tf.html#buh8h8y-
2Z[Last accessed on Date: 22.10.2017 Time: 12.28 AM]

You might also like