EEE 325 Control Systems
LAB # 06
Names MUHAMMAD SAAD KHAN
AINA QAMAR
Registration FA19-BEE-141
Numbers FA19-BEE-223
Class BEE-5D
Instructor’s Name SIR RIZWAN AZAM
Lab Assessment
Post Lab Total
Pre- In-
Data Data Writing
Lab Lab
Presentation Analysis Style
COMSATS University Islamabad
Introduction:
Given below is brief description of new MATLAB functions used in this lab
SERIES:
>>sys = SERIES(sys1,sys2)
Series connects two LTI models in series. This function accepts any type of LTI model. The two
systems must be either both continuous or both discrete with identical sample time. Static gains are
neutral and can be specified as regular matrices.
PARALLEL:
>>sys = parallel(sys1,sys2)
Parallel connects two LTI models in parallel. This function accepts any type of LTI model. The two
systems must be either both continuous or both discrete with identical sample time. Static gains are
neutral and can be specified as regular matrices.
FEEDBACK:
>>sys = FEEDBACK(sys1,sys2,±1
Feedback connects two systems in feedback order, where sys1 is the forward path gain, sys2 is the
feedback path gain and ±1 specifies positive and negative feedback respectively.
CONNECT: Used for block-diagram interconnections of LTI models.
Name-based interconnection:
In this approach, you name the input and output signals of all LTI blocks SYS1, SYS2, in the block
diagram, including the summation blocks. The aggregate model SYS is then built by
SYS = CONNECT(SYS1,SYS2,...,INPUTS,OUTPUTS)
COMSATS University Islamabad
PreLab Task:
Implement the following example in MATLAB
Given SISO LTI models C and G, you can construct the closed-loop transfer T from r to y using
CONNECT function.
[Link] = 'e'; [Link] = 'u';
[Link] = 'u'; [Link] = 'y';
Sum = sumblk('e','r','y','+-');
T = CONNECT (G,C,Sum,'r','y')
Code:
C=tf([1],[1 1]);
G=tf([1],[1 1]);
[Link] = 'e'; [Link] = 'u';
[Link] = 'u'; [Link] = 'y';
Sum = sumblk('e','r','y','+-');
T = connect(G,C,Sum,'r','y')
step(T)
COMSATS University Islamabad
Graph:
In this task, I simply implemented the code given in the prelab to understand the syntax and the way
block diagram is written via MATLAB code. And I use step as input.
COMSATS University Islamabad
INLAB TASKS:
CODE:
sys1= tf([1],[1 1])
sys2= tf([1],[1 1])
sys3= tf([1],[1 1])
OutputA= series(sys2,sys3)
Output= series(sys1,OutputA)
step(Output)
Graph:
COMSATS University Islamabad
Figure shows the step response of transfer functions in series
Simulink:
Figure shows the block diagram in simulink of transfer functions in series
COMSATS University Islamabad
Graph via workspace:
Figure shows the step response obtained from simulink of transfer functions in series
In this task, a series block diagram is implemented via a MATLAB code and output is verified by
implementing the same block diagram in SIMULINK.
COMSATS University Islamabad
Code:
sys1= tf([1],[1 1])
sys2= tf([1],[1 1])
sys3= tf([1],[1 1])
OutputA= parallel(sys2,sys3)
Output= parallel(sys1,OutputA)
step(Output)
Graph:
COMSATS University Islamabad
Figure shows the step response of transfer functions in parallel
Simulink:
Figure shows the block diagram in simulink of transfer functions in parallel
Graph via workspace:
COMSATS University Islamabad
Figure shows the step response of transfer functions in parallel obtained from simulink
In this task, parallel blocks are implemented in MATLAB and results are verified through
SIMULINK.
COMSATS University Islamabad
Code:
sys1= tf([1],[1 1])
sys2= tf([1],[1 1])
sys3= tf([1],[1 1])
sys4= tf([1],[1 4])
sys5= tf([1],[1 5])
out1= series(sys2,sys3)
out2= series(sys4,sys5)
out3=feedback(out1,out2)
Output=series(sys1,out3)
step(Output)
Graph:
Figure shows the step response of transfer functions using feedback function
COMSATS University Islamabad
Simulink:
Figure shows the block diagram in simulink of transfer functions using feedback function
Graph via workspace:
Figure shows the step response we got from Simulink of TFs with feedback function
In this task, a feedback system is implemented in MATLAB by using the command feedback.
Results are verified using SIMULINK.
COMSATS University Islamabad
Figure:
COMSATS University Islamabad
Code:
g1=tf([1],[1 1]);
g2=tf([1],[1 1]);
g3=tf([1],[1 1]);
g4=tf([1],[1 1]);
g5=tf([1],[1 1]);
g6=tf([1],[1 1]);
g7=tf([1],[1 1]);
[Link]='f';[Link]='e';
[Link]='b';[Link]='a';
[Link]='o';[Link]='a';
[Link]='d';[Link]='a';
[Link]='g';[Link]='e';
[Link]='c';[Link]='h';
[Link]='k';[Link]='c';
sum1=sumblk('a','r','f','k','+--');
sum2=sumblk('e','b','o','++');
sum3=sumblk('i','o','d','++');
sum4=sumblk('h','c','i','g','-++');
Y=connect(g1,g2,g3,g4,g5,g6,g7,sum1,sum2,sum3,sum4,'r','c');
COMSATS University Islamabad
step(Y)
Graph:
Figure shows the step response of block diagram in (i)
COMSATS University Islamabad
Simulink:
Figure show block diagram in simulink of figure in (i)
Graph:
Figure shows the step response of block diagram in (i) obtained via simulink
COMSATS University Islamabad
In this task, connect command is implemented to connect all the blocks. Sumblk command was
used where summer is encountered. The results obtained for step response in MATLAB are cross
verified using SIMULINK.
Task-2:
COMSATS University Islamabad
Labelled block diagram:
Code:
g1=tf([1],[1 1]);
g2=tf([1],[1 1]);
g3=tf([1],[1 1]);
g4=tf([1],[1 1]);
g5=tf([1],[1 1]);
g6=tf([1],[1 1]);
g7=tf([1],[1 1]);
g8=tf([1],[1 1]);
[Link]='b';[Link]='a';
[Link]='i';[Link]='c';
[Link]='g';[Link]='c';
[Link]='k';[Link]='c';
[Link]='m';[Link]='l';
[Link]='f';[Link]='e';
COMSATS University Islamabad
[Link]='e';[Link]='l';
[Link]='d';[Link]='e';
sum1=sumblk('a','r','h','+-');
sum2=sumblk('c','b','d','++');
sum3=sumblk('n','g','k','++');
sum4=sumblk('h','m','i','++');
sum5=sumblk('l','f','n','-+');
Y=connect(g1,g2,g3,g4,g5,g6,g7,g8,sum1,sum2,sum3,sum4,sum5,'r','e');
step(Y)
Graph:
Figure shows the step response of block diagram in (i)
Simulink:
COMSATS University Islamabad
Figure shows the block diagram on simulink of block diagram in (ii)
Graph via workspace:
Figure shows the step response of block diagram in (i) obtained via simulink
COMSATS University Islamabad
In this task, connect command is implemented to connect all the blocks. Sumblk command was
used where summer is encountered. The results obtained for step response in MATLAB are cross
verified using SIMULINK.
Calculation:
From the given fact Plant=Motor=1/[s(s+6)] and controller=k
We get that a=6 So
K=a^2/2 = 6^2 / 2 = 36 / 2 = 18
K = 18
Task-1:
Code (with controller):
num=[0 0 1];
den=[1 6 0];
plant=tf(num,den)
num=[18];
den=[1];
k=tf(num,den)
[Link]='u';[Link]='e';
[Link]='y';[Link]='u';
COMSATS University Islamabad
sum=sumblk('e','y','r','-+')
T=connect(plant,k,sum,'r','y');
step(T)
GRAPH:
Figure show step response of figure in question
COMSATS University Islamabad
Simulink (with controller):
Figure show step response of figure in question
Graph:
Figure show step response of figure in question obtained from simulink
COMSATS University Islamabad
Code (without controller):
num=[0 0 1];
den=[1 6 0];
plant=tf(num,den)
[Link]='y';[Link]='u';
sum=sumblk('u','y','r','-+')
T=connect(plant,sum,'r','y');
step(T)
GRAPH:
Figure shows step response
COMSATS University Islamabad
Simulink (without controller):
Figure shows block diagram
Graph:
Figure show step response fro simulink
In this task, step response is observed using controller and without controller. Without controller,
step response is achieving its steady state slowly and by using controller, step response died slowly.
We can say that we obtained impulse response and a stable system using controller.
COMSATS University Islamabad
Conclusion:
In this lab, we learnt how to implement the block diagrams in MATLAB. We learnt about new
commands like connect, feedback, sumblk, series parallel and also learn how to use these commands
in MATLAB. Also, step responses of different systems were observed in MATLAB and they were
verified by implementing all the models in SIMULINK.
COMSATS University Islamabad