Eng. Samir A.
Farag Part 3: Block diagram reduction using MATLAB
Example 1: Consider the case where ( ) , and ( ) . Obtain the closed-loop
( )
( )
transfer function ( ) R(s) + C(s)
G1(s)
- -
using MATLAB. G2(s)
Using MATLAB (six steps)
clc; clear all; close all;
% 1. define the transfer function for all blocks individually
G1=tf([1],[1 1 0]); % G1(s)=1/s(s+1)= 1/(s^2 + s + 0)
G2= tf([2],[1 0]); % G2(s)=2/s= 2/(s + 0).
G3= tf([1],[1]); % add a bock of unity gain in the input
% 2. append all blocks from the first to the last
T1=append(G1 , G2 , G3);
% 3. describe the inputs for each main block from the first to the last (# rows= # main blocks)
Q=[1 -2 -1 3; 2 -2 -1 3]; (# column= # the greatest summing point inputs + 1)
% 4. Specify input and output for block diagram
input=3; % the input is applied on the 3rd block, i.e. G3(s)
output=1; % the output is across the 1st block, i.e. G1(s)
% 5. connect the block diagram blocks appended in T1 as specified by Q taking into
%consideration that the input and output are specified as in input and output respectively.
Ts=connect(T1 , Q , input , output);
tf(Ts); % 6. Return the transfer function for block diagram
% 6. Return (the minimal realization or pole-zero cancellation for) the transfer function for the
%block diagram
minreal(tf(Ts))
Eng. Samir A. Farag 1 Block Diagram Reduction using MATLAB
Example 2:
Reduce the block diagram shown in
Figure P5.1 to a single transfer
function, T(s)= C(s)/R(s) Using
MATLAB
Answer
clc; clear all; close all;
% 1. define the transfer function for all
%blocks individually
G1=tf([1],[1 0 0]); %G1= 1/s^2
G2=tf([50],[1 1]); %G2= 50/(s+1)
G3=tf([2],[1 0]); %G3= 2/s
G4=tf([1 0],[1]); %G4= s
G5=tf([2],[1]); %G5= 2
G6=tf([1],[1]); %G6= 1
G7=tf([1],[1]); % G7= 1
% 2. append all blocks from the first to the last
allblocks= append(G1 , G2 , G3 , G4 , G5 , G6 , G7); % include all blocks
% 3. describe the inputs for each main block from the first to the last
Q=[1 -6 7; 2 1 -3 ; 3 2 0 ; 4 2 0 ; 5 2 0 ; 6 4 -5];
% 4. Specify input and output for block diagram
input=7; output=6;
% 5. connect the block diagram blocks appended in allblocks as specified by Q taking into
%consideration that the input and output are specified as in input and output respectively
Ts=connect(allblocks , Q , input , output);
% 6. Return the transfer function for block diagram
tf(Ts)
% 6. Return (the minimal realization or pole-zero cancellation for) the transfer function for the
%block diagram
minreal(Ts)
Eng. Samir A. Farag 2 Block Diagram Reduction using MATLAB
Example 3: Consider the control system whose block diagram is shown below. Where,
( ) , ( ) , ( ) , ( ) , ( ) , , and
H3(s)
-
R(s) + + + C(s)
G1(s) G2(s) G3(s) G4(s)
- - -
H1(s) H2(s)
Using MATLAB
clc; clear all; close all;
% 1. define the transfer function for all blocks individually
G1= tf([1],[1 10]); %G_1 (s)=1/(s+10)
G2= tf([1],[1 1]); %G_2 (s)=1/(s+1)
G3= tf([1 0 1],[1 4 4]); %G_3 (s)=(s^2+1)/(s^2+4s+4) ,
G4= tf([1 1],[1 6]); %G_4 (s)=(s+1)/(s+6)
H1= tf([1 1],[1 2]);%H_1 (s)=(s+1)/(s+2)
H2= tf([1 1],[1 4]); %H_2=(s+1)/(s+4)
H3= tf([1 5],[1 2]); % H_3=(s+5)/(s+2)
Gi=tf([1],[1]); % Gi= 1
% 2. append all blocks from the first to the last
T1=append(G1, G2, G3, G4, H1, H2, H3, Gi);
% 3. describe the inputs for each main block from the first to the last
Q=[1 8 -4 0; 2 1 -5 -7; 3 2 0 0; 4 3 -6 0; 5 2 0 0; 6 4 0 0; 7 4 0 0];
% 4. Specify input and output for block diagram
input= 8; % input is applied on the eighth block
output= 4; % output is across the 4th block
% 5. connect the block diagram blocks appended in T1 as specified by Q taking into
%consideration that the input and output are specified as in input and output respectively.
Eng. Samir A. Farag 3 Block Diagram Reduction using MATLAB
Ts=connect(T1,Q,input,output);
% 6. Return (the minimal realization or pole-zero cancellation for) the transfer function for the
%block diagram
minreal(tf(Ts))
Example 4: Consider the control system whose block diagram is given below. Where,
( ) , ( ) , ( ) , ( ) , ( ) , , and
H2(s)
-
R(s) + + +
G3(s) G4(s)
C(s)
G1(s) G2(s)
- -
H1(s)
H3(s)
Using MATLAB:
clc; clear all; close all;
G1= tf([1],[1 10]); % G_1 (s)=1/(s+10)
G2= tf([1],[1 1]); %G_2 (s)=1/(s+1),
G3= tf([1 0 1],[1 4 4]); %G_3 (s)=(s^2+1)/(s^2+4s+4) ,
G4= tf([1 1],[1 6]); %G_4 (s)=(s+1)/(s+6),
G5=tf([2],[1]); % H2
G6= tf([1 1],[1 2]); % H_1 (s)=(s+1)/(s+2),
G7=tf([1],[1]); % H3
G8=tf([1],[1]);
T1=append(G1, G2, G3, G4, G5, G6, G7, G8);
Eng. Samir A. Farag 4 Block Diagram Reduction using MATLAB
Q=[1 8 -7; 2 1 -5; 3 2 -6; 4 3 0; 5 3 0; 6 4 0; 7 4 0];
input= 8; output= 4;
Ts= connect(T1 , Q , input , output);
minreal(tf(Ts)) %Try: tf(Ts)
ans =
0.5 s^4 + 1.5 s^3 + 1.5 s^2 + 1.5 s + 1
------------------------------------------------------------
s^6 + 19 s^5 + 130.5 s^4 + 480.5 s^3 + 865 s^2 + 773 s + 366
Example 5:
Find the closed-loop transfer function,
T(s)= C(s)/R(s) for the system shown in
Figure P5.2, using block diagram
reduction. Where,
( ) , ( ) , ( ) and
( ) .
Answer
clc; clear all; close all;
G1=tf([1],[1 0 0]); %G1= 1/s^2
G2=tf([50],[1 1]); %G2= 50/(s+1)
G3=tf([2],[1 0]); %G3= 2/s
H1=tf([1 0],[1]); %H1= s
T1=append(G1,G2,G3,H1);
Q=[1 5 -4 0; 2 1 0 0; 3 2 5 -4 ; 4 1 0 0];
input= 5; % input is applied directly to block 5
output= 3;
Ts=connect(T1 , Q , input , output);
tf(Ts);
minreal(tf(Ts))
ans =
2 s^3 + 2 s^2 + 1.066e-14 s + 100
---------------------------------
s^4 + 2 s^3 + s^2
Eng. Samir A. Farag 5 Block Diagram Reduction using MATLAB
Problem 6:
Find the transfer function, T(s)=
C(s)/R(s), for the system shown in
Figure P5.5 using MATLAB.
Where,
( ) ( )
( ) ( )
( ) ( )
( ) ( )
Answer
clc; clear all; close all;
G1=tf([1],[1 7]); %G1=1/(s+7 )
G2=tf([1],[1 2 3]); %G2=1/(s^2+2s+3)
G3=tf([1],[1 4]); %G3=1/s+4
G4=tf([1],[1 0]); %G4=1/s
G5=tf([0 5],[1 7]); %G5=5/(s+7)
G6=tf([1],[1 5 10]); %G6=1/(s^2+5s+10)
G7=tf([3],[1 2]); %G7=3/(s+2)
G8=tf([0 1],[1 6]); %G8=1/(s+6)
G9=tf([1],[1]);
T1=append(G1,G2,G3,G4,G5,G6,G7,G8,G9);
Q=[1 9 -2 -5; 2 1 8 0; 3 1 8 0; 4 1 8 0; 5 3 4 -6; 6 7 0 0; 7 3 4 -6; 8 7 0 0];
input= 9; output= 7;
Ts=connect(T1 , Q , input , output); minreal(tf(Ts))
ans =
6 s^7 + 132 s^6 + 1176 s^5 + 5640 s^4 + 1.624e04 s^3 + 2.857e04 s^2
+ 2.988e04 s + 1.512e04
---------------------------------------------------------------------
s^10 + 33 s^9 + 466 s^8 + 3720 s^7 + 1.867e04 s^6 + 6.182e04 s^5
+ 1.369e05 s^4 + 1.981e05 s^3 + 1.729e05 s^2 + 6.737e04 s
- 1.044e04
Eng. Samir A. Farag 6 Block Diagram Reduction using MATLAB
Problem 7:
Find the transfer function, T(s)=
C(s)/R(s), for the system shown in Figure
P5.7 using MATLAB.
Answer
clc; clear all; close all;
G1=tf([1 0],[1]); %G1=1/(s+7)
G2=tf([2 0],[1]); %G2=2s
G3=tf([1 0],[1]); %G3=s
G4=tf([1],[1 1]); %G4=1/(s +1)
G5=tf([4],[1]); %G5=4
G6=tf([1],[1]); %G6=1
T1=append(G1,G2,G3,G4,G5,G6);
Q=[1 6 -4 0 0; 2 6 -4 0 0; 3 1 2 -3 0; 4 3 2 -5 -4; 5 4 0 0 0];
input= 6; output= 4;Ts=connect(T1,Q,input,output); tf(Ts)
ans =
0.8333 s^2 + 0.3333 s - 1.608e-15
---------------------------------
s^2 + 1.5 s + 1
Problem 8:
Find the equivalent
transfer function, T(s)=
C(s)/R(s), for the system
shown in Figure P5.3.
Eng. Samir A. Farag 7 Block Diagram Reduction using MATLAB
Answer
clc; clear all; close all;
G1= tf([1],[1 10]); % G_1 (s)=1/(s+10)
G2= tf([1],[1 1]); %G_2 (s)=1/(s+1)
G3= tf([1 0],[1 0 4]); %G_3(s)=s/(s^2+4)
G4= tf([1 1],[1 6]); %G_4 (s)=(s+1)/(s+6)
G5=tf([2],[1]); % G_5(s)= 2
G6= tf([1 1],[1 2]); % G6_(s)=(s+1)/(s+2)
G7=tf([1],[1]); % G_7(s)= 1
G8=tf([1],[1]);
T1=append(G1, G2, G3, G4, G5, G6, G7, G8);
Q=[1 8 -7 0 0; 2 8 -1 -7 0; 3 8 -1 -7 0; 4 8 -1 -7 0; 5 2 3 0 0; 6 5 3 4 -6; 7 6 0
0 0];
input= 8; output= 6;
Ts= connect(T1 , Q , input , output);
minreal(tf(Ts)) %Try: tf(Ts)
ans =
0.3333 s^5 + 5.333 s^4 + 33.67 s^3 + 125.3 s^2 + 119.3 s + 156
--------------------------------------------------------------
s^5 + 17 s^4 + 92.33 s^3 + 232 s^2 + 343.3 s + 396
Sunday, January 10, 2021
Samir A. Farag
Assistant Teacher at Electrical and computers Engineering department,
Higher Technological Institute (H.T.I), Industrial Area 2 – Next to Small
Industries Complex P.O. Box 228- 10th of Ramadan city, Egypt.
M.Sc. from Computer and Systems Engineering department, Faculty of
engineering, Zagazig University, Egypt, July 26, 2017 (Issue: Control of
Large Crane Structure).
PhD program at Electrical Power and Machines Department, Faculty of
engineering, Cairo University.
Facebook group: Mr. Eng. Samir A. Farag.
e-mail: [email protected]
Eng. Samir A. Farag 8 Block Diagram Reduction using MATLAB