Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

System Analysis using Laplace Transform

1. Polynomials
In Matlab, a polynomial is represented by a vector. To create a polynomial in Matlab, simply
enter each coefficient of the polynomial into the vector in descending order. For instance, let's
say you have the following polynomial:

s 4 3s 3 15s 2 2s 9
To enter this into Matlab, just enter it as a vector in the following manner
x = [1 3 -15 -2 9]
x=
1 3 -15 -2 9
Matlab can interpret a vector of length (n+1) as an nth order polynomial. Thus, if your
polynomial is missing any coefficients, you must enter zeros in the appropriate place in the
vector. For example,

s4 1
would be represented in Matlab as:
y = [1 0 0 0 1]
You can find the value of a polynomial using the polyval( ) function. For example, to find the
value of the above polynomial at s=2,
z = polyval([1 0 0 0 1], 2)
z=
17
You can also extract the roots of a polynomial. This is useful when you have a high-order
polynomial such as

s 4 3s 3 15s 2 2s 9

Finding the roots would be as easy as entering the following command;


roots([1 3 -15 -2 9])
ans =
-5.5745
2.5836
-0.7951
0.7860
You can also construct a polynomial using poly( ) function.
r = [-1, -2];
p = poly(r);
ans = 1 3 2
You can interpret that the resulting polynomial is given by

s 2 3s 2

2. Partial fraction expansion to perform inverse transform


In Matlab, you can perform partial fraction expansion using residue( ) function. The
following is how to use the residue( ) function:
Usage: [r, p, k] = residue(num, den)
r is PFE coefficients
p is poles
k is direct term

Example 1
You would like to find the inverse Laplace Transform of F(s) given by
F ( s)

s 2 12
s 3 5s 2 6 s

For this you have to decompose F(s) into simple terms uing partial fraction expansion:
Matlab code
num =[1 0 12];
% Generate numerator polynomial
den = [1 5 6 0];
% Generate denominator polynomial
[r,p,k] = residue(num, den)
This gives the following answer:
% Result:
r=
7.0000
-8.0000
2.0000
p=
-3.0000
-2.0000
0
k=
[]

Example 2:
Find the inverse Laplace Transform of
I L (s)

384 10 5
s ( s 2 64,000 s 16 10 8 )

In order to find it, we need to perform partial fraction expansion. The following Matlab
M-File provides us with the partial fraction expansion coefficients.
Matlab code
num = [38400000];
den = [1 64000 1600000000 0];
[r, p, k] = residue(num, den)
This gives the following answer:
r=
-0.0120 + 0.0160i
-0.0120 - 0.0160i
0.0240
p=
1.0e+004 *
-3.2000 + 2.4000i
-3.2000 - 2.4000i
0
k=
[]
The above results indicate that we have the following expression for I L (s ) :
I L ( s)

24 10 3
20 10 3 126.87
20 10 3 126.87

s
s 32,000 j 24,000 s 32,000 j 24,000

Simple manipulation shown in the class ends up with the current in the time domain :
i L (t ) 24 10 3 40 10 3 e 32, 000t cos( 24,000t 126.87 ) [A]

3. Time Domain Responses from Transfer Function G(s)


3.1 System responses and associated commands
Consider a transfer function shown below:
G(s) = p(s)/q(s) = num(s)/den(s).
We can create a LTI system by using
sys = tf(num,den)
where output sys is the tf object. (Type "help ltiprops" for details.)
Now, we can compute the various time domain responses from the transfer function
object using the following commands:
1) Impulse response
yi = impulse(sys,t)
2) Step response
ys = step(sys,t)
3) Responses to general inputs
yg = lsim(sys,u,t)
Note: t represents time (column) vector, u represents input (column) vector, and yi, ys,
and yg are all column vectors.
Example 3
Compute the impulse and step response from t = 0 to t = 10 of the following transfer
function:
G(s)

10
s 2s 10
2

Matlab code
t=[0:0.1:10]'; % Generate time vector
num=10;
% Assign numerator polynomial
den=[1 2 10]; % Assign denominator polynomial
sys = tf(num,den);
y_i = impulse(sys,t);
y_s = step(sys,t);

% Compute impulse response


% Compute step response

title('Output of Example 3.1')


subplot(2,1,1), plot(t,y_i), ylabel('Impulse response') % plot impulse response
subplot(2,1,2), plot(t,y_s), ylabel('Step response') % plot step response
xlabel('time in seconds')
This gives you the plot below:

In order to compute the response to ramp function and noise, we can do the following
procedures.
ramp=t;
% Generate ramp function
noise=rand(101,1);
% Generate 101 by 1 random vector
y_g = lsim(sys,ramp,t);
y_n = lsim(sys,noise,t);

% Compute the response to ramp function


% Compute the response to random noise

figure
title('Output of Example 3.1: LSIM( )')
subplot(2,1,1), plot(t,y_g), ylabel('Ramp response') % plot response to ramp input
subplot(2,1,2), plot(t,y_n), ylabel('Noise response') % plot response to noise

xlabel('time in seconds')
This gives you the following plot.

Example 4
From a parallel RLC circuit, we can derive the transfer function which is given by
H ( s)
(1)

I L (s)
1.6 10 9
2
I S ( s ) s 64,000 s 16 10 8

Compute the impulse response and unit step response from t = 0 to t = 0.5 msec.

Matlab code
t=[0: 0.1*10^(-6): 0.5*10^(-3)]'; % Generate time vector
num=[1.6*10^9];
% Assign numerator polynomial
den=[1 64000 16*10^8];
% Assign denominator polynomial
mysys = tf(num,den);
y_i = impulse(mysys,t); % Compute impulse response
y_s = step(mysys,t);
% Compute step response
figure
subplot(2,1,1), plot(t,y_i), ylabel('Impulse response') % plot impulse response
subplot(2,1,2), plot(t,y_s), ylabel('Unit step response') % plot step response
xlabel('time in seconds')
This gives you the plot below:

Impulse response

20000
15000
10000
5000
0
-5000

0.5

1.5

2.5

3.5

4.5

5
-4

x 10
Unit step response

1.5
1
0.5
0

0.5

1.5

2
2.5
3
time in seconds

3.5

4.5

5
-4

x 10

(2)

Compute the responses of the circuit when the input u1 (t ) 0.024 [A] and
u 2 (t ) 0.024 cos( 40,000t ) [A], respectively from t = 0 to t = 0.5 msec.

Matlab code
u1 = 0.024*ones(5001,1);
y1 = lsim(mysys,u1,t);
% Compute the response to step input
u2 = 0.024*cos(40000*t);
y2 = lsim(mysys,u2,t);
% Compute the response to sinusoidal input
figure
subplot(2,1,1), plot(t,y1), ylabel('Step response') % plot response to step input
subplot(2,1,2), plot(t,y2), ylabel('Sinusoidal response') % plot sinusoidal response
xlabel('time in seconds')
This gives you the following plot.

Step response

0.025
0.02
0.015
0.01
0.005
0

0.5

1.5

2.5

3.5

4.5

5
-4

x 10
Sinusoidal response

0.02
0.01
0
-0.01
-0.02

0.5

1.5

2
2.5
3
time in seconds

4. Transfer Function Utilities


9

3.5

4.5

5
-4

x 10

4.1 Basic commands


Consider a transfer function shown below:
G(s) = p(s)/q(s) = num(s)/den(s).
(1) Display the transfer function
printsys(num,den)
(2) Ploynomial from roots
den = poly([root1 root2 root3])
(3) Find poles and zeros from the transfer function
[z,p,k] = tf2zp(num,den)
where z (zeros) and p(poles) are column vectors and k is the gain
(4) Draw the pole zero map
pzmap(num,den) or pzmap(sys)
(5) Build transfer function from known poles and zeros
[num1, den1] = zp2tf(z,p,k)
where num1 and den1 are row vectors.

Example 5
Consider the transfer function which is given by
G (s)

( s 0.5)
s 2 2s 3

(a) Find the poles and zeros


(b) Draw pole-zero plot
Matlab code
num=[1 0.5]; den=[1 3 2];
sys1 = tf(num,den);
% Create LTI object
(1) Display the transfer function
sys1

10

% (2) Find poles and zeros from the transfer function


[z,p,k] = tf2zp(num,den), sys2 = zpk(sys1)
% z and p are column vectors
% k is the gain
[p1,z1] = pzmap(sys2)
figure
pzmap(sys2) % Without LHS, pzmap( ) plot the poles and zeros.
axis([-2.4 0.5 -1.0 1.0])
Note: zpk( ) function can also create LTI object from know poles and zeros.
Pole-zero map

1
0.8
0.6

Imag Axis

0.4
0.2
0
-0.2
-0.4
-0.6
-0.8
-1

-2

-1.5

-1
Real Axis

-0.5

0.5

4.2 Connections of two transfer functions


(1) Series connection: Gs(s) = G1(s) G2(s)
sys_s = series(sys1,sys2)
where sys1 is a LTI object of G1(s) and sys2 isa LTI object of G2(s).
(2) Parallel connection: Gp(s) = G1(s) + G2(s)
sys_p = parallel(sys1,sys2)

11

You might also like