You are on page 1of 7

Performing Mathematical Operation and

Performance Analysis in MATLAB


Abidur Rahman Sagor Towfiq Mahmud Mridul Enamul Haque Emon
18-38599-2 18-37866-2 18-38107-2
Department of EEE,
American Department of EEE, American Department of EEE, American
International University- International University- International University-
Bangladesh Bangladesh Bangladesh
Dhaka, Bangladesh Dhaka, Bangladesh Dhaka, Bangladesh
abidsagor83@ieee.org mridulmahmud55@gmail.com enamulemon32@gmail.com

Moniruzzaman MD.Nahid Hasan Niloy Gourab Deb


18-38213-2 18-37894-2 18-37309-1
Department of EEE, American Department of EEE, American Department of EEE, American
International University- International University- International University-
Bangladesh Bangladesh Bangladesh
Dhaka, Bangladesh Dhaka, Bangladesh Dhaka, Bangladesh
monshovon123@gmail.com niloypbt@gmail.com gourabdeb66@gmail.com

o ROW matrix/ row vector is defined to


Abstract - This lab report represents the mathematical express Laplace transform expressions.
operation and performance analysis in MATLAB. In this Variable coefficients are defined in left
lab different codes were written on MATLAB to perform to right descending power of ‘s’ format.
different mathematical operations such as partial fraction For example, deng = [500 0 0]
expansion, simplification, pole-zero determination, o SERIES: Series is the interconnection of
Laplace transformation, inverse Laplace transformation
the two Linear Time Invariant models.
and state space model generation from a given equation.
Then analysis of the second order systems were
understood by using Simulink. Lastly, the results of the
second order systems were compared in MATLAB and
Simulink along with the state response for various values
of zeta.
Index-

I. INTRODUCTION
MATLAB allows designers to perform complicated SYS=SERIES(SYS1,SYS2,OUTPUTS1,INPU
mathematical calculations in fast and efficient manner. TS2) connects two LTI models. SYS1 and SYS2
Partial fraction expansion, simplification, pole-zero are in series such that the outputs of SYS1
determination, Laplace transform, inverse Laplace specified by OUTPUTS1 are connected to the
transform, state-space model generation are some of the inputs of SYS2 specified by INPUTS2. The
mathematical operation that can be very easily performed vectors OUTPUTS1 and INPUTS2 contain
in MATLAB. Performing Laplace and inverse Laplace indices into the outputs and inputs of SYS1 and
transforms are mathematical methods. They are widely SYS2, respectively. The resulting LTI model
used in control systems. After performing Laplace SYS maps u1 to y2.
transforms, different mathematical operations can be If OUTPUTS1 and INPUTS2 are omitted, SERIES
applied to them. Students will learn to implement them connects SYS1 and SYS2 in cascade and returns
using MATLAB. SYS = SYS2 * SYS1
SYS = SERIES (SYS1, SYS2,'name') connects SYS1
To view the step response of a particular system for a and SYS2 by matching I/O names. The output names
particular transfer function, unit step function is given as an of SYS1 and input names of SYS2 should be fully
input. The output is then the step response. specified.
If SYS1 and SYS2 are arrays of LTI models, SERIES
II. THEORY AND METHODOLOGY returns an LTI array SYS of the same size where
SYS(:,:,k)=SERIES(SYS1(:,:,k),SYS2(:,:,k),OUTPUT
MATLAB Functions: S1,INPUTS2) .

1|P a g e
o PRINTSYS: Print system in pretty format o TF: Creation of transfer functions or
and is used to print state space systems with conversion to transfer function. Creation:
labels to the right and above the system SYS = TF(NUM,DEN) creates a
matrices or to print transfer functions as a continuous-time transfer function SYS with
ratio of two polynomials. numerator(s) NUM and denominator(s)
PRINTSYS (NUM, DEN,'s') or PRINTSYS DEN. The output SYS is a TF object.
(NUM,DEN,'z') prints the transfer function as o ZPK Create zero-pole-gain models or
a ratio of two polynomials in the transform
convert to zero-pole-gain format. Creation:
variable 's' or 'z'.
SYS = ZPK (Z, P, K) creates a continuous-
o FEEDBACK: Feedback connection of two time zero-pole-gain (ZPK) model SYS with
LTI models. zeros Z, poles P, and gains K. The output
SYS = FEEDBACK (SYS1, SYS2) SYS is a ZPK object.
an LTI model SYS for the closed - o The sym command creates symbolic
loop feedback system
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
Negative feedback is assumed and the resulting system command:
SYS maps u to y. To apply positive feedback, use the
syntax:
o pretty(X) prints symbolic output of X in a
SYS = FEEDBACK (SYS1, SYS2, +1). format that resembles typeset mathematics.
o laplace(f) computes the Laplace transform
o STEP: Step response of LTI models of f.
[Y,T] = STEP(SYS) returns the output o ilaplace(F) computes the Inverse Laplace
response Y and the time vector T used for transform of F.
simulation. No plot is drawn on the screen. o SIMPLIFY Simplify representation of
If SYS has NY outputs and NU inputs, and
Uncertain objects
LT = length(T), Y is an array of size [LT
NY NU] where Y(:,:,j) gives the step o SIMPLIFY Simplify representation of
response of the j-th input channel. Uncertain objects
[Y,T,X] = STEP(SYS) also returns, for a B = SIMPLIFY(A) performs model-
state-space model SYS, the state trajectory reduction-like techniques to detect and
X, a LT-by-NX-by-NU array if SYS has eliminate redundant copies of uncertain
NX states. elements. Depending on the result, the
o POLY: Convert roots to polynomial. CLASS of B may be lower than A. The
POLY(A), when A is an N by N matrix, is a AutoSimplify property of each uncertain
row vector with N+1 elements which are element in A determines what reduction
methods are used. After reduction, any
the coefficients of the characteristic
uncertain element which does not actually
polynomial, DET(lambda*EYE(SIZE(A)) -
affect the result is deleted from the
A) .
representation.
o RESIDUE: Partial-fraction expansion
(residues). [R,P,K] = RESIDUE(B,A) finds
the residues, poles and direct term of a o TF2SS: Transfer function to state-space
partial fraction expansion of the ratio of two conversion.
polynomials B(s)/A(s). If there are no [A,B,C,D] = TF2SS(NUM,DEN) calculates
multiple roots, the state-space representation of the system:
x = Ax + B
B(s) R(1) R(2) R(n)
---- = -------- + -------- + ... + -------- + K(s)
y = Cx + Du
A(s) s - P(1) s - P(2) s - P(n) o Time limit is selected using t=[ lower
limit : interval : upper limit]. For example, t
Vectors B and A specify the coefficients of the =
numerator and denominator polynomials in descending [ 0:0.1:20]
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.

2|P a g e
2

III. SIMULATION 1.8

1.6

MATLAB CODE:
1.4

Segment 1: 1.2

wheel velocity
1

clc; 0.8

clear all; 0.6

close all; 0.4


numg=[0 0 1];
deng=[500 0 0];
0.2

numc=[1 1]; 0
0 0.5 1 1.5 2 2.5 3

denc=[1 2]; time [sec]

[num,den]=series(numg,deng,numc,denc); Segment 3:
printsys(num,den)
[num_c, den_c]= cloop(num,den,-1); numy=32;
printsys(num_c,den_c) deny=poly([0 -4 -8]);
[r,p,k]=residue(numy,deny)

Segment 4:
Segment 2:
numf=150*[1 2 7];
num=[5400]; denf=[1 5.4 0];
den=[2 2.5 5402]; F=tf(numf,denf)
t=[0:0.005:3];
[y,x,t]=step(num,den,t);
figure(1)
plot(t,y), grid
xlabel('time [sec]')
ylabel('wheel velocity')

Segment 5:

numg=[-2 -4];
deng=[-7 -8 -9];
k=20;
G=zpk(numg,deng,k)

3|P a g e
Segment 6: Segment 8:

syms s; num=[2 8 6];


F1=2/[(s+1)*(s+2)^2]; den=[1 8 18 6];
pretty(F1); [A,B,C,D]=tf2ss(num,den);
f1=ilaplace(F1) printsys(A,B,C,D)
pretty(f1);
F2=3/[s*(s^2+2*s+5)];
pretty(F2);
f2=ilaplace(F2)
pretty(f2);

Segment 9:

syms s
A=[0 1 0;0 0 1; -1 -2 -3];
B=[10;0;0];
C=[1 0 0];
D=0;
I=[1 0 0;0 1 0;0 0 1];
Y=C*((s*I-A)^-1)*B+D;

Segment 7: Segment 10:


syms t t=[0:0.1:20];
f=2*exp(-t)-2*t*exp(-2*t)-2*exp(-2*t); num=[1];
pretty(f); zeta1=0.1;
F=laplace(f) den1=[1 2*zeta1 1];
pretty(F); zeta2=0.7;
F=simplify(F) den2=[1 2*zeta2 1];

4|P a g e
zeta3=1; REFERENCES
den3=[1 2*zeta3 1];
zeta4=0; [1] Norman S. Nise, “Control Systems Engineering”,
den4=[1 2*zeta4 1]; available Edition, John Wiley & Sons Inc.
zeta5=2; [2] https://www.mathworks.com/campaigns/products/trials
den5=[1 2*zeta5 1]; .html
[y1,x,t]=step(num,den1,t);
[y2,x,t]=step(num,den2,t);
[y3,x,t]=step(num,den3,t);
[y4,x,t]=step(num,den4,t);
[y5,x,t]=step(num,den5,t);
figure(2)
plot(t,y1,t,y2,t,y3,t,y4,t,y5)
xlabel('Wnt')
ylabel('y(t)')
title('step response of 2nd order systems for
variousvalues of zeta'),grid

step response of 2nd order systems for variousvalues of zeta


2

1.8

1.6

1.4

1.2
y(t)

0.8

0.6

0.4

0.2

0
0 2 4 6 8 10 12 14 16 18 20
Wnt

V. DISCUSSION

In this experiment we learn the characteristics of


MATLAB. We also learned how to solve various kinds of
MATLAB functions for various mathematical operations,
like as partial fraction expansion, simplification, pole-zero
determination, Laplace transformation, inverse Laplace
transformation, state space representations were observed
and solved using MATLAB. We also understood all the
mathematical operations

VI. CONCLUSION

In this experiment the introduction of MATLAB was given.


we learned how to perform various kinds of mathematical
calculation using MATLAB. We interpret the data and with
the help of MATLAB we easily get the results. which were
observed and we understood those mathematical operations
Such as partial fraction, simplification, pole-zero
determination, Laplace transformation, inverse Laplace
transformation, state space representations, transfer
function to state space.

5|P a g e
6|P a g e
F
cc

You might also like