Control Systems Lab 01
Control Systems Lab 01
Lab Viva
Student name Reg. No. Report Marks Total/15
Marks / 10 /5
1. Objectives of Lab 1
Laplace transform is an important tool that is very useful when we work with differential
equations. We will also use Laplace transforms in the control systems course. In this
handout we will only show how to find the Laplace/ inverse Laplace transforms in
MATLAB. The use of Laplace transforms in control systems theory will be shown in later
weeks.
In MATLAB, to display the result of any command you skip the semicolon at the end.
The inverse Laplace transform can be found using the function ilaplace(), for
example you can give the following command:
ilaplace(G1s)
You will agree that it is a lot easier to use a software tool to calculate the transforms in
comparison to doing it manually.
Find the inverse Laplace transform of the following frequency domain functions.
Tip: You will have to start by defining a symbolic variable for frequency.
i. G1 s =
ii. G2 s =
iii. G3 s =
iv. G4 s =
NOTE: You can do the exercise in the command window or using a MATLAB script (m
file). I suggest that you use the m file, because you can save it. This comment also
applies to the rest of MATLAB exercises in all the labs.
MATLAB Control System Toolbox provides industry-standard algorithms and tools for
systematically analyzing, designing, and tuning linear control systems. It is an important
tool for control engineers and is widely used in industry and academia. We can access
the Control System Toolbox by doing the following steps
• Open MATLAB
• Click Start (the start button inside MATLAB)
• Go to Toolboxes
• Click on the Control System Toolbox
In this handout we will introduce some of the basic functions in the Control Systems
Toolbox. We will show you how to use the Control Systems Toolbox to enter the
transfer function in MATLAB and how to plot the poles and zeros of a transfer functions.
In future labs we will look at more advanced functionalities of the Control Systems
Toolbox.
In this handout we will discuss two ways of entering transfer functions in MATLAB. The
first way if by using the function tf(). For using this function you will need two arrays
that represent the coefficients of the numerator polynomial and denominator
polynomial of the transfer function. For example if you have the transfer function
5 + 10
+ 7 + 12
then you can enter it into MATLAB with the following code:
num = [5 10]; %(coefficients of numerator)
den = [1 7 12]; %(coefficients of denominator)
G1 = tf (num,den) %(make transfer function)
Exercise 2
Find the poles and zeros of the transfer function given above in your logbook.
Remember the zeros are the roots of the numerator polynomial and poles are the roots
of the denominator polynomial.
Another way to enter transfer functions in MATLAB is by using the function zpk(). This
function lets you create a transfer function by just specifying the values of zeros, poles
and the gain. For example, the transfer function given above can also be written in the
form
5 +2
+3 +4
You can create this transfer function in MATLAB with the following code:
z = [-2]; %(zeros)
p = [-3 -4]; %(poles)
k = 5; %(gain)
G2 = zpk (z,p,k) %(make transfer function)
Once you have entered a transfer function in any of the above forms, you can easily
convert it to the other form. You can convert G2 to the usual form by using the
command tf(G2). You can also convert G1 to the zero-pole-gain form by using the
command zpk(G1).
Create the following transfer functions in MATLAB and convert them to the other form.
Give each transfer function a different name, e.g. G1, G2 etc.
30s − 180
s + 4s + 13s + 7
s +s+1
s +s +6
s + 4 s + 2 − 4i s + 2 + 4i
s − 2 s + 4 s + 5i s − 5i
s + 5s + 6
s% + 4s + 15s + 35
s −1
s & + 4s + 6s + 4
Once you have entered the transfer function in MATLAB, you can plot the poles and
zeros of the transfer function by using the command pzplot(). Here is some example
code
G1 = tf([5 10],[1 2 4 -3]) %(make transfer function)
pzplot(G1) %plot the poles and zeros
Exercise 4
Plot the poles and zeros of any three transfer functions that you have already created in
the MATLAB.
1.5
0.5
Imaginary Axis
-0.5
-1
-1.5
-2
-2 -1.5 -1 -0.5 0 0.5 1
Real Axis
Simulink is a very useful component of MATLAB that allows you to create models in
form of block diagrams and analyze/simulate these models. It is used by engineers all
over the world. In this section, you will learn how to create a model in Simulink using a
given transfer function.
To start Simulink click on the Simulink icon in the MATLAB window. See Figure 3 for
details.
A Simulink file is called a Simulink model. Create a new model by going to File -> New ->
Model.
Exercise 5
30s − 180
s + 4s + 13s + 7
s +s+1
s +s +6
b
s+a c
where the parameter a=2, b=3 and c=6.
First we will create the transfer function block and enter the values shown in the figure
below:
Now we have to specify the values of these parameters. For this go to File->Model
properties->Callback->InitFcn. Here you can write a script to initialize the values of
parameter. See the figure below for details.
In this handout we have only shown you how to create models in MATLAB and Simulink.
In later weeks we will also analyze and simulate it.