Basic

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Control System Laboratory Dept

of ETE, CUET 1

DEPARTMENT OF ELECTRONICS AND TELECOMMUNICATION ENGINEERING


CHITTAGONG UNIVERSITY OF ENGINEERING AND TECHNOLOGY
CHATTOGRAM – 4349, BANGLADESH

Experiment No. 1

Introduction to MATLAB and Basic Concepts Related to Control Systems

PRECAUTIONS:
• Students must carefully read the lab manual before coming to lab to avoid any
inconveniences.
• Students must carry a flash drive to transfer files and lab manuals.
• Use of mobile phone in lab is strictly prohibited and punishable offence.
OBJECTIVES:
• To familiarize with MATLAB and its various parts.
• To learn handling polynomials and Laplace Transform.
FUNCTIONS:
Commands Description Example
Row Vector Polynomial representation in To represent,
Y = [ …. ] MATLAB. A polynomial is P(S) = 𝑆4 + 3𝑆3 − 15𝑆2 − 2𝑆 + 9
represented by a row vector. Only MATLAB Command:
the coefficients of the polynomials >> p = [1 3 -15 -2 9]
are entered through the keyboard.
To represent, P(S)
= 𝑆3 + 1
MATLAB Command:
>> p = [1 0 0 1]
polyval( ) Evaluates a given polynomial at a To evaluate y = 2𝑆2 + 3𝑆 + 4 at S = 1
given point. MATLAB Command:
>> y = [2 3 4]
>> s = 1
>> val = polyval(y,s) val
=9
roots( ) Find the roots of a polynomial. To find the roots of 𝑆2 + 3𝑆 + 2 = 0
MATLAB Command:
>> p = [1 3 2] >>
r = roots(p)
r = -2
-1

conv( ) Convolves two polynomials. To find the product of two polynomials


(𝑆 + 2) and 𝑆2 + 4𝑆 + 8 MATLAB
Command:
>> x = [1 2]
>> y = [1 4 8] >>
z = conv(x,y) z =
Control System Laboratory Dept
of ETE, CUET 2

1 6 16 16
deconv( ) Deconvolve two polynomials. Divide the polynomial z
by y if,
z = 𝑆3 + 6𝑆2 + 16𝑆 + 16 y
= 𝑆2 + 4𝑆 + 8 MATLAB
Command:
>> z = [1 6 16 16]
>> y = [1 4 8]
>>[x, r] = deconv(z, y)
x=
12r
=
0000
poly( ) To form a polynomial equation Determine the quadratic equation whose
from its roots or to find the roots are 2 + 3i and 2 – 3i
characteristics equation of a MATLAB Command:
matrix. >> r = [2 + 3i; 2 – 3i] >>
p = poly(r)
p= 1
–4 13
printsys( ) To print a rational fraction from its Print the function:
numerator and denominator. 𝑆+3
𝐺(𝑆) = 2 + 2𝑆 + 3
𝑆

MATLAB Command:
>> num = [1 3]
>> den = [1 2 3]
>> printsys(num,den)

residue( ) To expand a rational fraction to Resolve the polynomial:


partial fractions or to get back the 𝑆2 + 9𝑆 + 1
rational fraction from partial
𝐺(𝑆) = 3+ 𝑆2 + 2𝑆 +
fractions.
1
𝑆
Into partial fractions.
MATLAB Command:
>> n = [1 9 1]
>> d = [1 1 2 1]
>> [r,p,k] = residue(n,d) r
=
1.0000 – 1.7678i
1.0000 + 1.7678i
-3.0000

p=
0.0000 + 1.4142i
0.0000 – 1.4142i
-1.0000

k=
1
tf2zp( ) and First one finds the zeros and poles Find the location of zeros and poles and
pzmap( ) from a transfer function and the plot the pole-zero map of the system
second one plots them on the S whose transfer function is given by,
Control System Laboratory Dept
of ETE, CUET 3

plane. 2𝑆2 + 8𝑆 + 6
𝐺(𝑆) =
4+ 6𝑆3 + 12𝑆2
+ 24𝑆
𝑆
MATLAB Command:
>> n = [2 8 6]
>> d = [1 6 12 24] >>
[z,p,k] = tf2zp(n,d) z
=
-3
5 -1
p=
0
-4.5198
-0.7401+2.1822i -0.7401-2.1822i
k=
2
>> pzmap(n,d)

zp2tf( ) Constructs transfer function from In the system,


given zeros and poles. Zeros are S = -3, -1
Poles are S = -2, -4, -6
The gain is 10
Construct the transfer function.
MATLAB Command:
>> z = [-3; -1]
>> p = [-2; -4; -6]
>> k = 10
>> [n,d] = zp2tf(z,p,k)
n = 0 10 40 30 d =
1 12 44 48

sysms t syms creates asymbolic object for Find the Laplace transform of:
laplace( ) time variable t. laplace and ilaplace F(t) = 𝑒−𝑡(1 − sin(𝑡))
ilaplace( ) can be used to find the Laplace MATLAB Command:
transform or inverse >> syms t
Laplace transform of any function. >> ft = exp(-t)*(1-sin(t))
>> fs = laplace(ft) fs =
1/(S+1) – 1/((S+1)^2+1)

>> ft = ilaplace(fs)
ft =
exp(-t) - exp(-t)*sin(t)

You might also like