You are on page 1of 87

Lab Practical # 01

An Introduction to MATLAB

Object: To become familiar with the basics of Mat lab.

Tools:
1) IBM PC
2) Mat lab 7 Version

Description:

What is MATLAB

The name MATLAB is short for Matrix Laboratory. It is a commercial software


package whose main function is to perform calculations on matrices, row vectors and
column vectors. It is widely used in both industry and academic institutions. It
possesses many of the features of a high level, numerically oriented programming
language, but in addition has a large collection of built-in functions for performing
matrix and vector operations in a way that is very simple for the user. For example, to
find the determinant of a matrix A one need only enter:

det(A)

MATLAB commands can be entered one line at a time, or the user can write programs
of MATLAB code and define his or her own functions. In this session, we shall only
use the one-line-at-a-time “interpretive” mode for simplicity, but the regular user will
find that the power of the package is considerably extended by writing his or her own
programs and functions.

Entering and quitting MATLAB

To enter MATLAB, simply double click on the MATLAB icon. To leave MATLAB
and return to the PC’s operating system
Simply type: quit
Aisha Muslim:

BS (TE)-044-07F

v = [2 4 7 5];
w = [1 3 8 9];

Exercise#1: Investigate the effect of the following commands:

(a) v(2) (b) sum = v + w (c) diff = w - v (d) vw = [v w]


(e) vw(2:6) (f) v'

(a) v(2)
ans =

(b) sum = v + w
sum =

3 7 15 14

(c) diff = w - v
diff =

-1 -1 1 4

(d) vw = [v w]
vw =

2 4 7 5 1 3 8 9

(e) vw(2:6)

ans =

4 7 5 1 3

(f) v'
ans =

2
4
7
5

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Now the matlab window shows all these commands excuted in command window

1
1
z= 
0 
 
0 
v = [2 4 7 5];

Exercise#2: Investigate the effect of the following commands

(i) z' (b) z*v (c) [v; w] (d) v*z (e) [z; v’] (f) z + v’

(i) z'
ans =

1 1 0 0

(b) z*v

ans =

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

2 4 7 5
2 4 7 5
0 0 0 0
0 0 0 0

(c) [v; w]
ans =

2 4 7 5
1 3 8 9
(d) v*z
ans =

Now the matlab window shows all these commands excuted in command window

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(e) [z; v']

ans =

1
1
0
0
2
4
7
5

(f) z + v'

ans =

3
5
7
5
Now the matlab window shows all these commands window executed in command
window;

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

1 2
M= 
3 4

Exercise#3:Investigate the effect of the following commands:

(a) N = inv(M) (b) M*N (c) I = eye(2) (d) M + I (e) M*z(1:2) (f) v(3:4)*M
(g) M(1,1) (h) M(1:2,1:2) (i) M(:,1) (j) M(2,:)

(a) N = inv(M)

N=

-2.0000 1.0000
1.5000 -0.5000

(b) M*N

ans =

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

1.0000 0
0.0000 1.0000

(c) I = eye(2)

I=

1 0
0 1

(d) M + I

ans =

2 2
3 5

Now the matlab window shows all these commands excuted in command window

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(e) M*z(1:2)

ans =

3
7

(f) v(3:4)*M

ans =

22 34

(g) M(1,1)

ans =

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(h) M(1:2,1:2)

ans =

1 2
3 4

(i) M(:,1)

ans =

1
3

(j) M(2,:)
ans =

3 4

Now the matlab window shows all these commands excuted in command window

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Exercise#4: Use the help command to find out about the following built-in functions
and make up your own simple examples:
1. ones 2. zeros 3. det 4. Linspace 5. Logspace

1. ones

ONES(N) is an N-by-N matrix of ones.


ONES(M,N) or ONES([M,N]) is an M-by-N matrix of ones.

2. zeros

ZEROS Zeros array.


ZEROS(N) is an N-by-N matrix of zeros.

ZEROS(M,N) or ZEROS([M,N]) is an M-by-N matrix of zeros.

3. det
DET Determinant.
DET(X) is the determinant of the square matrix X.

4. Linspace

LINSPACE Linearly spaced vector.


LINSPACE(X1, X2) generates a row vector of 100 linearly
equally spaced points between X1 and X2.

5. Logspace

LOGSPACE Logarithmically spaced vector


LOGSPACE(X1, X2) generates a row vector of 50 logarithmically
equally spaced points between decades 10^X1 and 10^X2. If X2
is pi, then the points are between 10^X1 and pi.

t=linspace(0,20,100);

Exercise#5:

1. Generate a vector yc containing the values of cos(t) for the time range given
above.
The program code is

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

ys = sin(t);

To plot the set of points type:


Plot(t,ys)
The basic graph can be prettied up using the following self explanatory
sequence of commands:
xlabel('Time in seconds')
ylabel('sin(t)')
title(' Roll No=44')
grid

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

2. From the “help” entry for “plot” find out how to get both ys and yc plotted against t
on the same axis.

PLOT Linear plot.


PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix,
then the vector is plotted versus the rows or columns of the matrix,
whichever line up. If X is a scalar and Y is a vector, length(Y)
disconnected points are plotted.

3. From the “help” entry for “subplot” find out how to plot ys and yc plotted on two
separate graphs, one above the other.

SUBPLOT Create axes in tiled positions.


H = SUBPLOT(m,n,p), or SUBPLOT(mnp), breaks the Figure window
into an m-by-n matrix of small axes, selects the p-th axes for
for the current plot, and returns the axis handle. The axes
are counted along the top row of the Figure window, then the
second row, etc. For example,

SUBPLOT(2,1,1), PLOT(income)
SUBPLOT(2,1,2), PLOT(outgo)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Lab Practical #02


Basic Control Functions

Exercise#1:

(a) Find zeros of transfer function (if any)

100
G(S) == 2
S +14S+100

Solution:

This function can be stored in the MATLAB workspace by typing


num = 100;
den = [1 14 100];
zeros=roots (num)
zeros =

Empty matrix: 0-by-1

(b) Is the above system stable? Why?


Answer:
yes, the system is stable because the real parts of complex poles lie in the left half
plane of the s plane.

(c) Use the plot function to plot the poles of the above transfer function marked by
the symbol ‘x’. Record this plot in your lab book with your Roll. No on the top
of the plot.

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Exercise#2:

(a) What is the difference between the built-in function “conv” and “series”?
Answer:
Conv: this function first computes the numerator and denominator of the
resultant transfer function separately by multiplying the respective entity.
Series: this is the built in function in mat lab to compute the transfer function of
two functions attached in series by accepting the four parameters of the num and
denominator of series functions.

(b) Reduce each of the following block diagrams into a single block form. In each
case find poles and zeros and sketch pole zero diagram. In which block diagrams
you cannot use the function “series”? Why? Also determine whether the system is
stable or not?

(i)
5(3S+27)
99
9S + 27 7(S3+12S2+9S+27

In these diagrams we can use the series function because there are only two blocks connected
in series. So the code for single block is
num1 = 99;
den1 = [9 27];
num2 = 5*[3 27];
den2 = 7* [1 12 9 27];
[num12, den12] = series (num1, den1, num2, den2);
printsys (num12, den12)

num/den =

1485 s + 13365
-------------------------------------------
63 s^4 + 945 s^3 + 2835 s^2 + 3402 s + 5103

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

poles=roots(den12)

poles =

-11.4189
-3.0000
-0.2905 + 1.5100i
-0.2905 - 1.5100i

zeros=roots(num12)
zeros =

-9
pzmap(poles,zeros)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The system is stable because all poles lie on the left half plane.

2S + 4 4/5 S2
(ii)
S3 S+3 S-6

In these diagrams we can not use the series function because there are three blocks connected in
series. So the code for single block is

num1 = [2 4];
den1 = [1 0 0 0];
num2 = 4/5;
den2 = [1 3];
num3=[1 0 0];
den3=[1 -6];

num12 =conv(num1,num2);
den12 = conv(den1,den2);

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

num123 =conv(num12,num3);
den123 = conv(den12,den3);
printsys (num123, den123)
num/den =

1.6 s^3 + 3.2 s^2


--------------------
S^5 - 3 s^4 - 18 s^3

poles=roots(den123)
poles =

0
0
0
6.0000
-3.0000

zeros=roots(num123)
zeros =

0
0
-2

The mat lab command window for above question is following;

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

pzmap(poles,zeros)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The system is unstable because pole of the function lie on the right half plane at s=6
as well as on the right half plane.

(iii)

2 S+6
S 9S 22
2
S+3 S +S+1 S+8 S + 5.6

In these diagrams we can not use the series function because there are three
blocks connected in series. So the code for single block is
num1 = [1 0 0];
den1 = [1 3];
num2 = [1 6];
den2 = [1 1 1];
num3=[9 0];
den3=[1 8];
num4=22;
den4=[1 5.6];

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

num12 =conv(num1,num2);
den12 = conv(den1,den2);
num123 =conv(num12,num3);
den123 = conv(den123,den3);
num1234 =conv(num123,num4);
den1234 = conv(den123,den4);
printsys (num1234, den1234)

num/den =

198 s^4 + 1188 s^3


-----------------------------------------------
s^7 + 10.6 s^6 - 14 s^5 - 379.2 s^4 - 806.4 s^3

poles=roots(den1234)
poles =

0
0
0
6.0000
-8.0000
-5.6000
-3.0000
zeros=roots(num1234)
zeros =

0
0
0
-6

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The mat lab window of the above question is following;

pzmap(poles,zeros)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Exercise#3
(a) Consider the following block diagram. Find the closed loop transfer function.

9
R(S) S+5 C(S)
-

Solution:
num1 = 9;
den1 = [1 5];
num2 = 1;
den2 = 1;
[n,d]=feedback(num1,den1,num2,den2);
printsys(n,d)
num/den =
9

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

------
s + 14

(b) Find the closed loop transfer function of the following block diagram.

S+2
R(S) 2
S +3S +12 C(S)
+

Solution:
num1 = [1 2];
den1 = [1 3 12];
num2 = 1;
den2 = 1;
[n,d]=feedback (num1, den1, num2,den2,+1);
printsys(n,d)
num/den =

s+2
--------------
s^2 + 2 s + 10

(c) Find the closed loop transfer function of the following block diagram.

1
R(S) S +1 C(S)
-

2
S
Solution:

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

num1 = 1;
den1 = [1 1];
num2 = 2;
den2 = [1 0];
[n,d]=feedback(num1,den1,num2,den2);
printsys(n,d)

num/den =

s
------------
s^2 + s + 2

(d) Find the closed loop transfer function of the following block diagram.

S
R(S) S +6 C(S)
-
num1 = [1 0];
den1 = [1 6];
num2 = [2 1]; 2S+1
den2 = [1 2]; S+2

[n,d]=feedback(num1,den1,num2,den2);
printsys(n,d)

num/den =

s^2 + 2 s
----------------
3 s^2 + 9 s + 12
The mat lab command window executing the above commands is shown as
following;

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Lab Practical # 03
Introduction to Simulink

Introduction
Simulink is a software package for modeling, simulating, and analyzing dynamic
systems. It supports linear and nonlinear systems, modeled in continuous time,
sampled time, or a hybrid of the two. One can easily build, analyze and visualize
models.
Thousands of engineers around the world using it to model and solve real problems.
Simulink provides a graphical user interface (GUI) for building models as block
diagrams, using click-and-drag mouse operations. With this interface, you can draw

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

the models just as you would with pencil and paper. Knowledge of this tool will serve
you well throughout your professional career.

Exercise#1: - Perform the indicated tasks using SIMULINK.

(a) Find the step response of the following transfer function.

G(S) = 1
S+1

Solution:
First in the untitled page of mat lab simulinks we created this model by copying the
blocks into the model from the respective Simulink block libraries:

• Sources library (the step response)


• Sinks library (the Scope block)
• Continuous library (the transfer function block)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The result of above after choosing the Start from the Simulation menu
and watch the simulation output on the Scope.

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(c) Differentiate the ramp function and check the result on the scope.

Solution:
First in the untitled page of mat lab simulinks, we created this model by copying the
blocks into the model from the respective Simulink block libraries:

• Sources library (the step response)


• Sinks library (the Scope block)
• Continuous library (the transfer function block)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

This is shown as below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The result of above after choosing the Start from the Simulation menu
and watch the simulation output on the Scope.

(d) Amplify sine wave using gain block.


Solution:
First in the untitled page of mat lab simulinks, we created this model by copying the
blocks into the model from the respective Simulink block libraries:

• Sources library (the sine wave)


• Sinks library (the Scope block)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

This is shown as below

After double clicking the gain block we get its properties block and setting the
gain from 1 to 2 first we get the amplified sine wave with the amplitude 2 even the
amplitude of the sine wave in the properties block is still 1 .

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Now the result on the scope is shown below after clicking the start from the
simulation menu.

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(e) Simulate the JK flip-flop in toggle mode and copy resultant waveform in your
answer book.
SOLUTION:

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(e) Explain briefly the function of each block you have used.
(f) Also explain in which library or sub-library this block is present?

1. Step block:
Generate a step function
Library
Sources
Description:
The Step block provides a step between two definable levels at a specified time. If the
simulation time is less than the Step time parameter value, the block's output is the
Initial value parameter value. For simulation time greater than or equal to the Step
time, the output is the Final value parameter value.

2. Transfer Fcn:
It Implements a linear transfer function

Library:
Continuous
Description:
The Transfer Fcn block implements a transfer function where the input (u) and output
(y) can be expressed in transfer function form.
A Transfer Fcn block takes a scalar input. If the numerator of the block's transfer
function is a vector, the block's output is also scalar. However, if the numerator is a
matrix, the transfer function expands the input into an output vector equal in width to
the number of rows in the numerator. For example, a two-row numerator results in a
block with scalar input and vector output. The width of the output vector is two.
3. Scope:
Display signals generated during a simulation
Library
Sinks
Description:
The Scope block displays its input with respect to simulation time. The Scope
block can have multiple axes (one per port); all axes have a common time range
with independent y-axes. The Scope allows to adjust the amount of time and the
range of input values displayed. We can move and resize the Scope window and
you can modify the Scope's parameter values during the simulation. When we
start a simulation, Simulink does not open Scope windows, although it does
write data to connected Scopes. As a result, if we open a Scope after a
simulation, the Scope's input signal or signals will be displayed. If the signal is

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

continuous, the Scope produces a point-to-point plot. If the signal is discrete,


the Scope produces a stair-step plot.

4. Gain :
Multiply the input by a constant
Library
Math Operations
Description :
The Gain block multiplies the input by a constant value (gain). The input and
the gain can each be a scalar, vector, or matrix. You specify the value of the
gain in the Gain parameter. The Multiplication parameter lets you specify
element-wise or matrix multiplication. For matrix multiplication, this parameter
also lets you indicate the order of the multiplicands. The gain is converted from
doubles to the data specified in the block mask offline using round-to-nearest
and saturation. The input and gain are then multiplied, and the result is
converted to the output data type using the specified rounding and overflow
modes.
5. Sine Wave:
Generate a sine wave
Library:
Sources
Description:
The Sine Wave block provides a sinusoid. The block can operate in either time-
based or sample-based mode.
Time-Based Mode:
The output of the Sine Wave block is determined by Time-based mode has two
submodes: continuous mode or discrete mode. The value of the Sample time
parameter determines whether the block operates in continuous mode or discrete
mode: 0 (the default) causes the block to operate in continuous mode. >0 causes
the block to operate in discrete mode.
Sample-Based Mode:
Sample-based mode uses the following formula to compute the output of the
Sine Wave block.
Y = a sin(2*pi*(k+0)/p+b)
where
A is the amplitude of the sine wave.
p is the number of time samples per sine wave period.
k is a repeating integer value that ranges from 0 to p-1.
o is the offset (phase shift) of the signal.
Control systems lab manual
Aisha Muslim:

BS (TE)-044-07F

b is the signal bias.


In this mode, Simulink sets k equal to 0 at the first time step and computes the
block's output, using the preceding formula. At the next time step, Simulink
increments k and recomputes the output of the block. When k reaches p,
Simulink resets k to 0 before computing the block's output. This process
continues until the end of the simulation.

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Lab Practical # 04
State Space Representation

1. Introduction:
A Control system can be represented as:

d/dx = Ax + BU

d/dx = Cx + DU
Where A, B, C and D are matrices, x is the state vector, y is the output vector and u is
the input vector. The above representation can be obtained from the differential
equation or transfer function of the system under considerations.
MATLAB has built-in functions tf2ss (transfer function to state space) and ss2tf (state
space to transfer function) to convert transfer function model into state space
representation and vice versa. Following examples demonstrate the use of both of
these functions.

Exercise#1: - Find the state space representation of the following transfer functions.
S+2
1).
G(S) =
S 2+ 7S + 12

Solution:
num= [1 2];
den= [1 7 12];
[A, B, C, D]=tf2ss (num, den);
printsys (A, B, C, D)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After executing the above code in command window of mat lab we get the
following result
a=
x1 x2
x1 -7.00000 -12.00000
x2 1.00000 0

b=
u1
x1 1.00000
x2 0

c=
x1 x2
y1 1.00000 2.00000

d=
u1
y1 0

(S+1)(S +2)
2). G(S) =
S(S 2+3S+1)
Solution: =
num= [1 3 2];
den= [1 3 1 0];
[A, B, C, D]=tf2ss (num, den);
printsys (A, B, C, D)

After executing the above code in command window of mat lab we get the
following result
a=
x1 x2 x3
x1 -3.00000 -1.00000 0
x2 1.00000 0 0
x3 0 1.00000 0

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

b=
u1
x1 1.00000
x2 0
x3 0

c=
x1 x2 x3
y1 1.00000 3.00000 2.00000

d=
u1
y1 0

Now the mat lab window shows the results of above questions:

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Exercise#2:

Find the transfer functions of the following systems

(a).

Solution:

A= [-1 0 0; 0 -2 -3; 0 0 3];


B= [3;-6; 3];
C= [1 1 1];
D=0;
[num, den] =ss2tf (A, B, C, D);
printsys (num, den)

After executing the above code in command window of mat lab we get the
following result

num/den =

4.2188e-015 s^2 + 9 s - 3
-------------------------
S^3 - 7 s - 6

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

2).
Solution:
A= [0 1 0; 0 0 1;-6 -11 -6];
B= [0; 0; 0];
C= [1 0 0];
D=0;
[num, den]=ss2tf (A, B, C, D);
printsys (num, den)

After executing the above code in command window of mat lab we get the
following result

num/den =

4.2188e-015 s^2 + 9 s - 3
-------------------------
S^3 - 7 s - 6

Eigen values

Exercise#3:
Find the Eigen values of the systems with

0 2 0 0 0
0.1 0.35 0.1 0.1 0.75
0 0 0 2 0
A= 0.4 0.4 -0.4 -0.4 0
0 -0.03 0 0 -1

A= [0 2 0 0 0;0.1 0.35 0.1 0.1 0.75;0 0 0 2 0;0.4 0.4 -0.4 -0.4 0;0 -0.03 0 0 -1];
B=eig (A)
After executing the above commands in mat lab command window we get;
B=

0.8061
Control systems lab manual
Aisha Muslim:

BS (TE)-044-07F

-0.2223 + 0.9426i
-0.2223 - 0.9426i
-0.4321
-0.9794
Now the mat lab window showing the above commands is given below;

b)... compute the eign values of the system given in exercise 2(a) and 2(b).
1).
Solution:

A= [-1 0 0; 0 -2 -3; 0 0 3];


B=eig (A)

After execution we get

B=

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

-1
-2
3

2).

Solution:
A= [0 1 0; 0 0 1;-6 -11 -6];
B=eig (A)
After execution we get

B=

-1.0000
-2.0000
-3.0000

State transition matrix

Exercise#4:

Find the state transition matrix of the following systems

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(a): System given in (a) at t=4;

Solution:
t=4;
A= [-1 0 0; 0 -2 -3; 0 0 3];
B=expm (A*t)
After execution of the above code we have

B=

1.0e+005 *

0.0000 0 0
0 0.0000 -0.9765
0 0 1.6275

b) System given in (b) at t=0;

Solution:
t=0;
A= [0 1 0; 0 0 1;-6 -11 -6];
B=expm (A*t)
After execution of the above code we have

B=
1 0 0
0 1 0
0 0 1

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Now the mat lab window shows the above all programs;

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Lab Practical # 05
Time Response of a Control System

1. Introduction

When a time domain signal is applied to a control system it produces a response of


that signal in time domain. This response of the system is called time response of a
control system. At the first instant the system exhibits some transients and after some
time it comes to steady state. While designing a control system the information of
transient response characteristics and the steady state characteristics is very important.
In this lab we will apply different test signals (Step, Impulse and Ramp) to a particular
control system and from the response of that signal we will acquire the information
about the peak response, steady state, settling time, rise time and steady state error.

Exercise#1: - Find transient and steady state characteristics of the following transfer
functions.

a).
num = [1 2];
den = [1 7 12];
step(num,den)
grid on

After executing in command window we get the following result

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

b).
num = [1 3 2];
den = [1 3 1 0];
step(num,den)
grid on

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Exercise#2: - Reduce the following open loop systems into a single block and find
time response of the system.

(i)

9(S+3)
S
2S2 + 9s +
9S + 17
27
Solution:

num1= [1 0];
den1= [9 17];
num2= [9 27];
den2= [2 9 27];
[num12, den12]=series (num1, den1, num2, den2);
printsys(num12, den12)

After executing the above code we get the single transfer function as

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

num/den =

9 s^2 + 27 s
------------------------------
18 s^3 + 115 s^2 + 396 s + 459
>>

Now for the transient and steady state response in terms of step input is

step (num12, den12)

The result in mat lab figure is following;

(ii)
2S + 4 4/5 S2
S3 S+3 S-6

num1 = [2 4];

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

den1 = [1 0 0 0];
num2 = 4/5;
den2 = [1 3];
num3=[1 0 0];
den3=[1 -6];
num12 =conv(num1,num2);
den12 = conv(den1,den2);
num123 =conv(num12,num3);
den123 = conv(den12,den3);
printsys (num123, den123)
After executing the above code we get the single transfer function as

num/den =

1.6 s^3 + 3.2 s^2


--------------------
S^5 - 3 s^4 - 18 s^3
Now for the transient and steady state response in terms of step input is
step(num123,den123)

The result in mat lab figure is following;

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Exercise#3: - Find time response of following closed loop systems.

(i)
9
R(S) S+5 C(S)
-

Solution:

num1 = 9;
den1 = [1 5];
num2 = 1;
den2 = 1;
[n,d]=feedback (num1, den1, num2, den2);

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

printsys(n,d)
For the equilent transfer function of the feedback system we get the following result
from mat lab command window;
num/den =
9
------
s + 14
Now for the transient and steady state response in terms of step input is

step(n,d)

The result in mat lab figure is following;

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(ii)
1
R(S) S +1 C(S)
-

2
S

Solution:
num1 = 1;
den1 = [1 1];
num2 = 2;
den2 = [1 0];
[n,d]=feedback(num1,den1,num2,den2);
printsys(n,d)
For the equilent transfer function of the feedback system we get the following result
from mat lab command window;

num/den =

s
------------
s^2 + s + 2
Now for the transient and steady state response in terms of step input is

step(n,d)

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The result in mat lab figure is following

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Lab Practical # 06
Time domain analysis of Second Order System

Introduction

Generalized transfer function of second order system is represented by the following


equation
ωn2
G(S) =
S2 + 2ςωnS +ωn2

Where ωn is the natural un-damped frequency and ς is damping ratio. Thus the
response of the second order system depends upon both factors. In this lab we will
analyze the effect of variation of damping ratio and natural un-damped frequency on
the response of the system.

Exercise#1: -

(a) Find Step response of the system when


ωn = 0.1 rad/sec

ς = 0.2, 0.5, 0.81, 2.5


ωn2
G(S) =
S2 + 2ςωnS +ωn2

After putting ς = 0.2 and ωn = 0.1 rad/sec we get the transfer function

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

0.01
G(S) = 2
S +0.04S+0.01
By entering the following MATLAB code we can find the step response of the system

num = 0.01
den = [1 0.04 0.01];
step (num, den)
grid on
The command window shows the value of the numerator as

num =

0.0100

The step response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 0.5 and ωn = 0.1 rad/sec we get the transfer function

0.01
G(S) = 2
S +0.01S+0.01
By entering the following MATLAB code we can find the step response of the system

num = 0.01
den = [1 0.01 0.01];
step (num, den)
grid on
The command window shows the value of the numerator as

num =

0.0100

The step response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 0.81 and ωn = 0.1 rad/sec we get the transfer function

0.01
G(S) = 2
S +0.162S+0.01
By entering the following MATLAB code we can find the step response of the system

num = 0.01
den = [1 0.162 0.01];
step (num, den)
grid on
The command window shows the value of the numerator as

num =

0.0100

The step response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 2.5 and ωn = 0.1 rad/sec we get the transfer function

0.01
G(S) = 2
S +0.5S+0.01
By entering the following MATLAB code we can find the step response of the system

num = 0.01
den = [1 0.5 0.01];
step (num, den)
grid on
The command window shows the value of the numerator as

num =

0.0100

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The step response figure is given below

(c).What is the effect of increasing the value of ς.

Answer:
The effect of increasing the value of damping ratio ς. in part (1) of the question is
that the system’s transient response is more stable and more time the system will
take to reach the steady state.

Exercise#2: -

(a) Find impulse response of the system when


ωn = 0.1 rad/sec
ς = 0.2, 0.5, 0.81, 2.5
ωn2
G(S) =
S2 + 2ςωnS +ωn2

After putting ς = 0.2 and ωn = 0.1 rad/sec we get the transfer function

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

0.01
G(S) = 2
S +0.04S+0.01
By entering the following MATLAB code we can find the impulse response of the
system
num = 0.01
den = [1 0.04 0.01];
impulse(num,den)
grid on

The command window shows the value of the numerator as

num =
0.0100

The impulse response figure is given below

After putting ς = 0.5 and ωn = 0.1 rad/sec we get the transfer function

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

0.01
G(S) = 2
S +0.01S+0.01

By entering the following MATLAB code we can find the impulse response of the
system
num = 0.01
den = [1 0.01 0.01];
impulse(num,den)
grid on

The command window shows the value of the numerator as

num =
0.0100

The impulse response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 0.81 and ωn = 0.1 rad/sec we get the transfer function
0.01
G(S) = 2
S +0.162S+0.01

By entering the following MATLAB code we can find the impulse response of the
system
num = 0.01
den = [1 0.162 0.01];
impulse(num,den)
grid on

The command window shows the value of the numerator as

num =
0.0100

The impulse response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 2.5 and ωn = 0.1 rad/sec we get the transfer function
0.01
G(S) = 2
S +0.5S+0.01

By entering the following MATLAB code we can find the impulse response of the
system
num = 0.01
den = [1 0.5 0.01];
impulse(num,den)
grid on

The command window shows the value of the numerator as

num =
0.0100

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The impulse response figure is given below

(b) What is the effect of increasing the value of ς.


Answer:
The effect of increasing the value of damping ratio ς. in part (1) of the question is
that the system’s transient response is more stable and more time the system will
take to reach the steady state.

Exercise#3: -

(a) Find ramp response of the system when


ωn = 0.1 rad/sec
ς = 0.2, 0.5, 0.81, 2.5
ωn2
G(S) =
S2 + 2ςωnS +ωn2

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 0.2 and ωn = 0.1 rad/sec we get the transfer function

0.01
G(S) = 2
S +0.04S+0.01

By using the following MATLAB code we can find the ramp response of the system

t=0:0.01:10;
r=t;
num = 0.01
den = [1 0.04 0.01];
plot(r,t)
hold on
lsim(num,den,r,t)
hold off
grid on

The command window shows the value of the numerator as

num =

0.0100

The ramp response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 0.5 and ωn = 0.1 rad/sec we get the transfer function

0.01
G(S) =
S 2+0.01S+0.01

By using the following MATLAB code we can find the ramp response of the system

t=0:0.01:10;
r=t;
num = 0.01
den = [1 0.01 0.01];
plot(r,t)
hold on
lsim(num,den,r,t)
hold off
grid on

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The command window shows the value of the numerator as

num =

0.0100

The ramp response figure is given below

After putting ς = 0.81 and ωn = 0.1 rad/sec we get the transfer function

0.01
G(S) = 2
S +0.162S+0.01

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

By using the following MATLAB code we can find the ramp response of the system

t=0:0.01:10;
r=t;
num = 0.01
den = [1 0.162 0.01];
plot(r,t)
hold on
lsim(num,den,r,t)
hold off
grid on

The command window shows the value of the numerator as

num =

0.0100

The ramp response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ς = 2.5 and ωn = 0.1 rad/sec we get the transfer function
0.01
G(S) = 2
S +0.5S+0.01
By using the following MATLAB code we can find the ramp response of the system

t=0:0.01:10;
r=t;
num = 0.01
den = [1 0.5 0.01];
plot(r,t)
hold on
lsim(num,den,r,t)
hold off
grid on

The command window shows the value of the numerator as

num =

0.0100

The ramp response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

(f) What is the effect on steady state error with the increasing the value of ς.
Answer:
The slope of the transient response of the system is more steepest after increasing
the value of ς.

Exercise#4: -

(a) Find step, ramp and impulse response of the system when
ωn = 0.1, 0.2, 0.5 and 1 rad/sec
ς = 0.2 ωn2
G(S) =
S2 + 2ςωnS +ωn2

Step responses:
After putting ωn = 0.1 and ς = 0.2 rad/sec we get the transfer function
0.01
G(S) = 2
S +0.04S+0.01

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

By entering the following MATLAB code we can find the step response of the system

num = 0.01
den = [1 0.04 0.01];
step (num, den)
grid on

The command window shows the value of the numerator as

num =

0.0100

The step response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ωn = 0.2 and ς = 0.2 rad/sec we get the transfer function
0.04
G(S) = 2
S +0.08S+0.04

By entering the following MATLAB code we can find the step response of the system

num = 0.04
den = [1 0.08 0.04];
step (num, den)
grid on

The command window shows the value of the numerator as

num =

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

0.0400

The step response figure is given below

After putting ωn = 0.5 and ς = 0.2 rad/sec we get the transfer function
0.25
G(S) = 2
S +0.2S+0.25

By entering the following MATLAB code we can find the step response of the system

num = 0.25
den = [1 0.2 0.25];
step (num, den)
grid on

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The command window shows the value of the numerator as

num =

0.2500

The step response figure is given below

After putting ωn = 1 and ς = 0.2 rad/sec we get the transfer function

1
G(S) = 2
S +0.4S+1

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

By entering the following MATLAB code we can find the step response of the system

num = 1;
den = [1 0.4 1];
step (num, den)
grid on

The command window shows the value of the numerator as

num =

1.0000

The step response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Impulse responses:
After putting ωn = 0.1 and ς = 0.2 rad/sec we get the transfer function
0.01
G(S) = 2
S +0.04S+0.01

By entering the following MATLAB code we can find the impulse response of the
system

num = 0.01
den = [1 0.04 0.01];
impulse (num, den)
grid on
The command window shows the value of the numerator as

num =

0.0100
The impulse response figure is given below

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ωn = 0.2 and ς = 0.2 rad/sec we get the transfer function
0.04
G(S) = 2
S +0.08S+0.04

By entering the following MATLAB code we can find the impulse response of the
system

num = 0.04
den = [1 0.08 0.04];
impulse (num, den)
grid on

The command window shows the value of the numerator as

num =

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

0.0400
The impulse response figure is given below

After putting ωn = 0.5 and ς = 0.2 rad/sec we get the transfer function
0.25
G(S) = 2
S +0.2S+0.25

By entering the following MATLAB code we can find the impulse response of the
system

num = 0.25
den = [1 0.2 0.25];
impulse (num, den)
grid on

The command window shows the value of the numerator as

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

num =

0.2500

The impulse response figure is given below

1
G(S) = 2
S +0.4S+1

By entering the following MATLAB code we can find the impulse response of the
system

num = 1;
den = [1 0.4 1];
impulse (num, den)
grid on

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The command window shows the value of the numerator as

num =

1.0000

The impulse response figure is given below

Ramp responses:
After putting ωn = 0.1 and ς = 0.2 rad/sec we get the transfer function
0.01
G(S) =
S 2+0.04S+0.01

By entering the following MATLAB code we can find the ramp response of the
system

t=0:0.01:10;
r=t;

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

num = 0.01
den = [1 0.04 0.01];
plot(r,t)
hold on
lsim(num,den,r,t)
hold off
grid on

The command window shows the value of the numerator as

num =

0.0100
The ramp response figure is given below:

After putting ωn = 0.2 and ς = 0.2 rad/sec we get the transfer function
0.04
G(S) = 2
S +0.08S+0.04

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

By entering the following MATLAB code we can find the ramp response of the
system

t=0:0.01:10;
r=t;
num = 0.04
den = [1 0.08 0.04];
plot(r,t)
hold on
lsim(num,den,r,t)
hold off
grid on

The command window shows the value of the numerator as

num =

0.0400
The ramp response figure is given below:

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

After putting ωn = 0.5 and ς = 0.2 rad/sec we get the transfer function
0.25
G(S) = 2
S +0.2S+0.25

By entering the following MATLAB code we can find the ramp response of the
system

t=0:0.01:10;
r=t;
num = 0.25;
den = [1 0.02 0.25];
plot(r,t)
hold on
lsim(num,den,r,t)
hold off
grid on

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

The command window shows the value of the numerator as

num =

0.2500
The ramp response figure is given below:

After putting ωn = 1 and ς = 0.2 rad/sec we get the transfer function


1
G(S) = 2
S +0.4S+1

By entering the following MATLAB code we can find the ramp response of the
system

t=0:0.01:10;
r=t;
num = 1;
den = [1 0.4 1];
plot(r,t)
hold on

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

lsim(num,den,r,t)
hold off
grid on

The command window shows the value of the numerator as

num =

1.0000
The ramp response figure is given below:

(b) What is the effect of increasing the value of ς.

Control systems lab manual


Aisha Muslim:

BS (TE)-044-07F

Control systems lab manual

You might also like