Professional Documents
Culture Documents
System Analysis Using Laplace Transform: 1. Polynomials
System Analysis Using Laplace Transform: 1. Polynomials
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
s 2 3s 2
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]
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);
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);
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
3.5
4.5
5
-4
x 10
Example 5
Consider the transfer function which is given by
G (s)
( s 0.5)
s 2 2s 3
10
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
11