EDXC3103 Control System1
EDXC3103 Control System1
A. Information on Students
Name of Student
Matric No
I/C No
Learning Centre (PPW/PPT)
General Guidelines:
1. Students must abide by the lab regulation accordingly.
2. Students should attend their laboratory sessions promptly and punctually.
3. Students will not be allowed to be in the lab alone and unsupervised.
4. Students must be properly attired at all times during the lab session.
5. Students are expected to keep the lab clean and tidy at all times.
6. Students must sign in and out when they come for the lab session.
7. Students must complete their labs work 10 minutes before the end of the session and
return all the material taken to the lab assistance.
1
B. Laboratory Session
Date
Venue
Time
Name of Demonstrator
C. Detail of Experiments
EXPERIMENT 1 Matlab Fundamentals
EXPERIMENT 2 Basic Graphics of Matlab
EXPERIMENT 3 Setting Up Control Problem
EXPERIMENT 4 Poles, Zeros and Time Response
2
Experiment 1 Matlab Fundamentals
1.1 Introduction
Matlab, an abbreviation of Matrix laboratory, was founded in 1984, Boston, USA. Major industries
involve in designing using Matlab including automotive, digital signal processing, aerospace, finance
and economic, automotive control and education.
Matlab is the engineering based computer software used to solve engineering problem in the matrix-
based system. Matlab are frequently used in analyzing and design control system. Matlab have many
predefined function and command that can be call by user to solve many types of control problem.
The Matlab family product consist of toolboxes, compiler, simulink, blocksets, stateflow and coder.
Toolboxes such as control system toolbox is used extensively for control system design, and being
compliment by the simulink.
Matlab can be started by double clicking on the Matlab icon. To change the default view, go to
VIEW, DESKTOP LAYOUT and choose any view the user preferred or depend on the application
need. User can quit the Matlab by typing exit or quit. To clear the command window, type clc. To
clear the function or command used, type clear. If user need help to search for more pre-defined
command, then type help. If the command name is known, then type help “command name”.
To learn the simple Matlab command, let us hand on, try the following simple examples:
Example 1
>> a = 4/3
>> a = 1.33333333333333
3
Example 2
Example 3
Example 4
4
>> c = [1 2 3;4 5 6;7 8 9]
>> c=
1 2 3
4 5 6
7 8 9
>> size(c)
>> ans = 3 3
>> a' % ' means transpose
>> ans =
1 3
2 4
>> c'
>> ans =
1 4 7
2 5 8
3 6 9
>> k=
1 0
0 2
Example 5
Let say the polynomial equation p = s2 + 5 s + 6. To factorise the equation, roots command is used.
>> p = [1 5 6];
>> roots(p) % factorise the equation
>> ans =
-3.0000
-2.0000
>> p=
1 5 6
ie (s+2)(s+3)
1 5 6
5
Example 6
>> i
>> ans = 0 + 1.0000i
>> j
>> ans = 0 + 1.0000i % Both i and j can be used
Example 7
Example 8
>> x=
1.0000
-1.0000
2.0000
6
Exercise 1
Question 1
3 (4) + 42 - 6
a) y =
6½+
(4 X 7 + 8)2
b) y =
7 + 3 1/4
Question 2
-5 1 0 0
Consider A = 0 -2 1 , b= 0 , c= -1 1 0
0 0 1 1
a) If Ax=B, find x.
b) yA= C, find y.
Question 3
1
a) G1(s) =
s2 + 4s + 1
20(s+1)
b) G2(s) =
s2+8s+3
7
2.1 Introduction
Human are very good at extracting information from the pictures. Matlab provides the plotting
command to help you take advantages of this ability to process data.
The plot function is used to produce 2- dimensional curves using x and y data. Besides, the plot
command allows character-string argument that designate various colour and lines styles for the
resulting lines.
Example 1
Figure Example 1
Example 2
8
>> grid on % creates grid on the graph
>> grid off % turn off the grid from the current figures.
To add additional figures, use hold on, then the current plot will be hold. Try the following:
>> x = 0:0.1:2*pi;
>> y = sin(x);
>> plot(x,y)
>> grid on
>> hold on
>> plot (x, exp(-x),’r:*’)
However, all this can be done without writing these commands. It can be done using the features
provided by the Matlab figure, go to Insert and many features are available. Try them out.
2.3 Subplots
9
You can display multiples plots in the same window with the subplot command. The advantage of
subplot is to plot a few graphs on the same page for the ease of comparison. Command subplot(m,n,p)
is used where m and n determine how many figure can accommodate into the same page. The m by n
determine the number of figure for row and column.
Example 3
>> subplot(2,2,1);
>> plot(1:10);
>> subplot(2,2,2);
>> x=0:0.1:2*pi;
>> plot(x,sin(x))
>> subplot(2,2,3)
>> plot(x,exp(-x),’r’)
>> subplot(2,2,4)
>> plot(peaks)
Figure Example 3
Exercise 2
a) y = cos2(x) where 0 < x < 2. Label both x and y axis as well as title to the graph.
2 Plot the following functions in the same graph using different style option, where t =
linspace(0,2*pi,100).
a) x=tcos(t), plot(t,x)
b) x=cos(t), plot(t,x)
c) x=sin(t), plot)t,x)
10
Label both axes and give a title to the graph. Also indicate each graph by using the command
gtext
3.1 Introduction
11
An understanding of connection among the different linear system is essential to the design of single
input and single output control system. In this chapter, participant will learn how to create the transfer
function, convert transfer function to state space and vice-versa and solving the transfer function of
the block diagram using various build in command.
1. tf2ss
2. ss2tf
3. series
4. parallel
5. feedback
Consider
Y 15(S + 20)
= G(s) = (1)
U (S +15)(S+25)(S+0.4)
where it is closed loop transfer function. To display this using Matlab command, try this:
The Matlab display the closed loop transfer function of equation (1).
1 2 1
a = 3 4 b= 0 c= 1 18
To display all matrixes above in the state space, try the following:
>> a = [1 2; 3 4];
>> b = [1 ; 0];
>> c = [1 18];
>> d = 0;
>> printsys(a,b,c,d)
Both transfer function and state-space can be converted using build in command tf2ss and ss2tf. Try
the following example:
12
Example 3.1
Y s+1
=
U s3+4s2+7s+6
Example 3.2
Consider the same matrix given in section 3.3 and D = 0, try the following to convert the
matrix to transfer function.
>> A = [1 2; 3 4];
>> B = [1;0];
>> C = [1 18];
>> D = 0;
>> (num,den)=ss2tf(A,B,C,D);
>> printsys(A,B,C,D)
Previous discussion was based on the single transfer function and state space model. Practically,
engineer encounter more complicated system with many block, feedback and closed loop. Commands
used are parallel, feedback and series.
13
Example 3.3
Using parallel command to determine the transfer function of the parallel connection of systems
1
s+3
+
U(s) Y(s)
+
s+4
s+10
>> num1 = 1;
>> den1 = [1 3];
>> num2 = [1 4];
>> den2 = [1 10];
>> [num,den] = parallel(num1,den1,num2,den2);
>> printsys(num,den)
s^2 + 8s + 22
Num/Den =
s^2 + 13s + 30
Example 3.4
s+6
s+12 H(s)
s^2 + 14s + 24
s^3 + 21s^2 + 119s + 192
14
Negative feedback is assumed and the resulting system maps R(s) to Y(s). To apply positive
feedback, use the following syntax
sys = feedback(sys1,sys2,+1)
Example 3
Using series and cloop command for block diagram with series and unity feedback system.
H(s) G(s)
s^2 + 9 s + 8
s^3 + 20 s^2 + 119 s + 208
15
Exercise 3
Question 1
Convert the following differentiation equation into transfer function and state space representation
using tf2ss and ss2tf. Y(s) is the output and U(s) is the input of the system
a) s2Y+4sY+5Y = 5U
b) s3Y+5s2Y+6sY+4Y = 8U
c) s3Y+4s2Y+8sY+9Y=(s+1)U
Question 2
For the following block diagram, find the transfer function of the system using Matlab command.
G2
U(s) + + + Y(s)
G1
H1
16
Experiment 4 Poles, Zeros and Time Response
4.1 Introduction
This chapter emphasizes the use of MATLAB tools for studying the relationship between the
poles and zeros of a linear time-invariant system. Since most of the control system can be
analysed using the test signal of unit step, we will focus on the step response and also impulse
response.
Example 4.1
The transfer function of the open loop control system of 5th order is given below:
3s4+2s3+8s2+4s+6
G(s) =
s5 +3s4+4s3+2s2+7s+6
The poles and zeros of the system can be found typing the following line.
Example 4.2
Control system with state space model is presented with matrix A, B and C.
>> A=[1 3; 4 6];
>> B=[1;0];
>> C=[1 0];
>> [z,p,k]=ss2zp(A,B,C,0)
>> z=6
p = -0.7720
7.7720
k=1
17
To see these zeros and poles of the control system on a plot of the complex plane, then use
the command pzmap(p,z).
Example 4.3
Repeat Example 1 and Example 2 with additional line of pzmap(p,z)
Example 4.4
>> z = [ 0; 0; 0; -1 ] ;
>> p = [ -1 +i 1-i -2 -3.15 + 2.63*i -3.15 + 2.63*i ];
>> k = 2;
>> [num,den]=zp2tf (z,p,k);
>> printsys (num, den)
2s^4 + 2s^3
num / den =
s^5 + 10.3s^4 + 48.04s^3 + 109.2s^2 + 126.2s + 67.36
It is also possible to use MATLAB to convert a list of poles, zeros and gain to a state – space
description. This is accomplished by means of the command zp2ss.
Example 4.5
18
For a system with one zero at –1 and three poles at –2, -1+ j and –1-j and a dc gain of 2, try the
following to convert the zero and poles to state space model.
Example 4.6
Let say the open loop transfer function of the system have no zero, poles at –1 and –4 and a
gain of 5. Then try the following
>> [num,den]=zp2tf ([ ] , [ -1+4*j - 1-4*j] ,5 ); % zeros and poles convert to tf
>> step(num,den) % unit step response
Exercise 4
Question 1
19
Simulate and plot the impulse and step response of the state space model given below:
-7 -30 -40 1
A= 1 0 0 B= 0 C = [2 11 5] D = [0]
0 1 0 0
Question 2
1.5s +1
G(s) =
s3+2s2+2.5s+0.5
Determine the stability of the system. Plot the poles and zeros of G(s) in the s-plane. Hence,
demonstrate system stability by simulating the impulse response.
Question 3
Simulate the output response due to unit step input signal. Use tstats to find Mp, tp, tr and ess.
Find the damping ratio and the undamped natural frequency of the closed system poles.
References:
2. Modern Control Systems, 9th Edition, Prentice Hall by R C Dorf and R H Bishop
20
3. Using Matlab To Analyse and Design Control Systems, 2 nd Edition, Addison
Wesley by N E Leonard and W S Levine
4. Feedback Control Problems Using Matlab and the Control System Toolbox, 1 st
Edition, Brooks/Cole, Thomson Learning by D K Frederick and J H Chow.
5. Control System Toolbox, For Use with Matlab, Getting Started Version 5,MATH
WORKS Inc
21