Вы находитесь на странице: 1из 6

UNITED INTERNATIONAL UNIVERSITY (UIU)

COURSE NO. EEE 402 (CONTROL SYSTEM LABORATORY)

EXPT. NO. 1

MATLAB BASICS FOR POLYNOMIAL, LAPLACE TRANSFORM, AND TRANSFER


FUNCTION

A. Handling Polynomial in MATLAB


The polynomials have a very significant role to play in engineering systems analysis. The polynomial
functions are stored in polyfun directory in MATLAB.
Some of the important commands and functions are tabulated below:
Row vector Polynomial representation .
y = [……..] In MATLAB, a polynomial is represented by a row vector. Only the coefficients of
the polynomials are entered through keyboard.

(i) To represent, p ( s )  s 4  3s 3  15s 2  2 s  9 (ii) To represent, p ( s )  s 3  1


MATLAB command : MATLAB command :
>> p = [1 3 -15 -2 9] p = [1 0 0 1]
or, or, p = [1,0,0,1]
>> p = [1,3 ,-15, -2, 9] Important !
MATLAB can interpret a vector of length n+1
as an nth order polynomial. Thus if there are
any missing terms, zeros must be entered in the
appropriate places in the vector.
polyval( ) Evaluates of a given polynomial at a given point.

To Evaluate y  2s 2  3s  4 at s = 1 >> s=1;


MATLAB command : >> value=polyval(y,s)
>> y=[2 3 4]; value =

roots( ) Finds the roots of a polynomial.


To find the roots of s  3s  2  0
2
>> r=roots(p)
MATLAB command : r=
>> p=[1 3 2]; -2
-1

conv( ) Multiplies two polynomials


(i)To find the products of two polynomials >> z=conv(x,y)
2
(s+2) and (s +4s+8) z=
MATLAB command : 1 6 16 16
>> x=[1 2]; Thus the product is , s 3  6 s 2  16 s  16
>> y=[1 4 8];
(ii) To find the products of three polynomials >> c=[1 6];
(s+3) , (s+2) and (s+6). (Nested conv( ) ). >> product=conv(conv(a,b),c)
MATLAB command : product =
>> a=[1 3]; 1 11 36 36
>> b=[1 2]; Thus the product is , s 3  11s 2  36 s  36
deconv( ) Division of two polynomials
Divide the polynomial z by y if, >> [x,r]= deconv(z,y)
z  s 3  6 s 2  16 s  16 x=
and, y  s  4s  8
2
1 2
MATLAB command : r =
>> z=[1 6 16 16]; 0 0 0 0
>> y=[1 4 8]; Note that, x is quotient and r is remainder.
poly( ) (i)To form a polynomial equation from it’s roots
(ii) To find the characteristics equation of a matrix.
[The characteristic polynomial of a matrix is,
sI-A=0
where, A is the given matrix and I is the identity matrix . ]

(i) Determine the quadratic equation whose 1 3 2


roots are 2+3i and 2-3i  5
A= 0 1
MATLAB command : 2 8 6
>> r=[2+3i;2-3i]; MATLAB command :
>> p=poly(r) >> A=[1 3 2;0 1 5;2 8 6];
>> p=poly(A)
p=
p=
1 -4 13
Thus the quadratic equation is, 1 -8 -31 8
s 2  4s  13  0 Thus, the characteristic equation is
s 3  8s 2  31s  8  0
(ii) Determine the characteristic equation of
the matrix given by,

tf( ) To form a transfer function from its numerator and denominator


s3 >>G= tf(num,den)
Print the fraction G  2 Transfer function:
s  2s  3
MATLAB command : s+3
>> num=[1 3]; -------------
>> den=[1 2 3]; s^2 + 2 s + 3

residue( ) (i) To expand a rational fraction to partial fractions :


[r,p,k] = residue(n,d)
(ii) To get back the rational fraction from the partial fractions:
[n,d] = residue(r,p,k)
s 3  9s  1 p=
(i)Resolve the polynomial
s 3  s 2  2s  2
into partial fractions. 0.0000 + 1.4142i
MATLAB command : 0.0000 - 1.4142i
>> n=[1 0 9 1]; -1.0000
>> d=[1 1 2 2];
>> [r,p,k]= residue(n,d) k=
1
r= Note that, here every r denotes numerator of
each partial fraction , every p denote poles of
1.0000 - 1.7678i every partial fraction and k is the general
1.0000 + 1.7678i constant.
-3.0000 Thus the partial fractions are,
1  1.7678i 1  1.7678i 3 >> k=1;
1  
s  1.4142i s  1.4142i s  1 >> [num,den]=residue(r,p,k)
Find the partial fraction of the output of a num =
system: 1.0000 0 9.0000 1.0001
1 s4 den =
C ( s )  R ( s ).G ( s )  .
s ( s  2)( s  3) 1.0000 1.0000 2.0000 2.0000

(ii)From the partial fractions >> printsys(num,den,'s')


1  1.7678i 1  1.7678i 3 num/den =
1   s^3 + 9 s + 1.0001
s  1.4142i s  1.4142i s  1
form the original rational fraction . --------------------
MATLAB command : s^3 + s^2 + 2 s + 2
s 3  9s  1
Thus the fraction is ,
>> r=[1.0000 - 1.7678i;1.0000 + 1.7678i;-3]; s 3  s 2  2s  2
>> p=[1.4142i;-1.4142i;-1];

B. Laplace Transform using MATLAB


Laplace Transform helps in converting differential equations describing the behavior of dynamic
systems into algebraic equations of complex variable s .Mathematically the Laplace Transform of the
function f(t) is given by, L{ f (t )}  F  s   0 e  st f  t  dt

Laplace transformation F(s) of a function f(t) and the inverse Laplace transform of a function F(s) can
be obtained as shown in the following table:

syms t syms t :
constructs a symbolic object for time variable t
laplace (ft) laplace(ft) :
finds the Laplace Transform of ft

Find the Laplace Transform of the function fs =


f  t   e (1  sin t )
t

MATLAB command : 1/(s+1)-1/((s+1)^2+1)


>> syms t; Thus the Laplace Transform is
>> ft=exp(-t)*(1-sin(t)); 1 1
F (s)  
>> fs=laplace(ft) s  1 ( s  1) 2  1

syms s t syms s t :
constructs symbolic objects for time t and the Laplace variable s
ilaplace(fs) ilaplace(fs):
finds the Inverse Laplace Transform of fs
Find the Inverse Laplace Transform of the
function, 1/4 -1/4*exp(-t)*cos(3^(1/2)*t)
2s  1 +7/12*3^(1/2)*exp(-t)*sin(3^(1/2)*t)
F (s) 
s  s  2 s  4
2
Thus, the inverse Laplace transform is
f (t )   e t cos 3t   e sin  3t 
MATLAB command : 1 1 7 3 t
>> syms s t; 4 4 12
>> fs=(2*s+1)/(s*(s^2+2*s+4));
>> ft=ilaplace(fs)
Find the Time-Domain representation of the
output of a system:
ft =
1 s4
C ( s )  R ( s ).G ( s )  .
s ( s  2)( s  3) Make sure that this is consistent with the output
found in the section of partial fraction

C. Transfer Function and Pole-zero Map

Input u(t) Output y(t)


System

Figure 1.1: A system showing input and output

Deriving transfer function from differential


equation of a system  ( as 2  bs  c)Y ( s )  ( ps  q )U ( s )
Consider a differential equation,
d2y dy du Y ( s) ps  q
a 2  b  cy  p  qu …………………    G( s)
dt dt dt U ( s ) as 2  bs  c
………….(i)
Taking Laplace Transformation of both sides ps  q
and putting all initial conditions to zero, we get,  G(s) 
as  bs  c
2
as 2Y ( s )  bsY ( s )  cY ( s )  psU ( s )  qU ( s )

tf2zp( ) tf2zp( ) finds the zeros poles and gains of a transfer function.
and pzmap( ) plots the pole zero map of the transfer function.
pzmap( )
Find the location of zeros and poles and plot 2
the pole-zero map of the system, whose
transfer function is given by, >> pzmap(n,d)
2 s  8s  6
2
F ( s)  4 Pole-Zero Map
s  6 s 3  12 s 2  24 s 2.5

MATLAB command : 2

>> n=[2 8 6]; 1.5


>> d=[1 6 12 24 0]; 1
>> [z,p,k]=tf2zp(n,d)
0.5
z=
Imaginary Axis

-3 0

-1 -0.5

p= -1

0 -1.5

-4.5198 -2
-0.7401 + 2.1822i
-2.5
-0.7401 - 2.1822i -5 -4.5 -4 -3.5 -3 -2.5 -2 -1.5 -1 -0.5 0
Real Axis
k=
pole and zero location using pzmap function.

zp2tf( ) Constructs transfer function from given zero pole

In a system : Zeros are at s = -3,-1


Poles are at s = -2,-4,-6 >> [n,d]=zp2tf(z,p,k);
The gain is 10 >> printsys(n,d,'s')
Construct the transfer function. num/den =
MATLAB command : 10 s^2 + 40 s + 30
>> z=[-3;-1]; ------------------------
>> p=[-2;-4;-6]; s^3 + 12 s^2 + 44 s + 48
>> k = 10;

D. Response of a System Through Transfer Function


Impulse response of a system Consider the transfer function :
Consider the differential equation : 3s  2
G ( s)  3
d3y d2y dy du 2 s  4 s 2  5s  1
2 3  4 2  5  y  3  2u
dt dt dt dt
(i) Create a TF object for the system Obtain a plot of the step response of the
(ii) Plot the impulse and step response system .
of the system MATLAB code :
Solution :
The transfer function is : n=[3 2]
3s  2 d=[2 4 5 1];
G ( s)  3
2 s  4 s 2  5s  1 G=tf(n,d)
step(G)
MATLAB code : grid

n=[3 2] Output :Transfer function:


d=[2 4 5 1]; 3s+2
G=tf(n,d) -----------------------
impulse(G) 2 s^3 + 4 s^2 + 5 s + 1
grid
Step Response
2

1.8
Output : 1.6
Transfer function: 1.4

3s+2 1.2

-----------------------
Amplitude

2 s^3 + 4 s^2 + 5 s + 1 0.8

The impulse response is shown below: 0.6

0.4
Impulse Response
0.7 0.2

0
0 5 10 15 20 25
0.6
Time (sec)

0.5 Figure 2.3


Step response of a system
0.4
Amplitude

0.3 Response to a general input :


0.2
Consider the transfer function :
3s  2
G ( s)  3
0.1
2 s  4 s 2  5s  1
0
0 5 10 15 20 25
Time (sec)

Figure 2.2 Obtain a plot of the response of the system to


(Impulse response of a system) an input given below :

Step response of a system


0 t0

x(t)  2 0t 2 The output is shown below:
0.5 t2

Input response to a system
2.5

MATLAB code : 2

n=[3 2]; d=[2 4 5 1 ]; G=tf(n,d)


1.5
t1=0: 0.02 : 2; t2=2.02: 0.02 : 10;

Amplitude
output

time=[t1 t2];
x = [2*ones(size(t1)) 0.5*ones(size(t2)) ]; 1

input
y=lsim(G,x,time); 0.5

plot(time,y,time,x,'--') 0
0 1 2 3 4 5 6 7 8 9 10
gtext('input') Time(Sec)

gtext('output') Figure 2.4


General input response of a system

C. Home Work:
1.1 Obtain the Laplace transform of the following f(t) using MATLAB.
i. f(t) = e 3t cos 4t
ii. f(t) = 1-2e-4t +e-5t
1.2 Obtain the inverse Laplace transform of the following F(s).
i. F(s) = (s5 + 8 s4 + 23 s3 + 35 s2 + 28 s + 3) / (s3 + 6 s2 + 8 s)
ii. F(s) = [10(s + 2) (s +4)] / [( s + 1) (s + 3) (s + 5)2 ]
1.3 Given the zeros, poles and gain K of B(s)/A(s). Obtain the function B(s)/A(s).
i. There is no zero. Poles are at -1 + 2j and 1  2j. K = 10.
ii. A zero is at 1. Poles are at 2, 4 and 8. K = 12.
1.4 Obtain a plot of the ramp response of the system whose transfer function is shown below:
3s  2
G ( s) 
2 s  4 s 2  5s  1
3

Вам также может понравиться