You are on page 1of 8

MATLAB Exercises 4

Instructions:
Go through the guide and paste your outputs on the provided space. When completing
the activity, rename the file to Last Name, First Name_Section_LBYME3F_MATLAB_Ex
no. (eg. Dela Cruz, Not Juan_EE1_ LBYME3F_MATLAB_1) and submit to
AnimoSpace.

Objectives:
• To be able to use the script file blkbuild and the function connect to convert block
diagram into state-space.
• To learn how to use the function series, parallel, and feedback in system
reduction.

Cascade Form
If several blocks are connected in series, they can be combined into a single block
whose transfer function is the product of the individual transfer function. This is
illustrated in figure below and its overall transfer function, G(s) is given by:

To do this in MATLAB, you can use the conv function. The function conv can be used
to multiply two polynomials. To illustrate, consider the two cascaded system whose
transfer function are:
𝑠+1
𝐺1 (𝑠) =
(𝑠 + 3)(𝑠 + 5)
𝑠 2 + 11𝑠 + 10
𝐺2 (𝑠) =
𝑠 3 + 19𝑠 2 + 102𝑠 + 156

The overall transfer function should be:


(𝑠 + 1)(𝑠 2 + 11𝑠 + 10)
𝐺 (𝑠 ) =
(𝑠 + 3)(𝑠 + 5)(𝑠 3 + 19𝑠 2 + 102𝑠 + 156)
Type,
≫ 𝑛𝑢𝑚 = 𝑐𝑜𝑛𝑣([1 1], [1 11 10]);
≫ 𝑑𝑒𝑛 = 𝑐𝑜𝑛𝑣(𝑐𝑜𝑛𝑣([1 3], [1 5]), [[1 19 102 156]);
≫ 𝑝𝑟𝑖𝑛𝑡𝑠𝑦𝑠(𝑛𝑢𝑚, 𝑑𝑒𝑛)

Output:

Another approach is to use the series function


≫ 𝑛𝑢𝑚1 = [1 1];
≫ 𝑑𝑒𝑛1 = 𝑐𝑜𝑛𝑣 ([1 3], [1 5]);
≫ 𝑛𝑢𝑚2 = [1 11 10];
≫ 𝑑𝑒𝑛2 = [1 19 102 156];
≫ [𝑛𝑢𝑚, 𝑑𝑒𝑛] = 𝑠𝑒𝑟𝑖𝑒𝑠(𝑛𝑢𝑚1, 𝑑𝑒𝑛1, 𝑛𝑢𝑚2, 𝑑𝑒𝑛2)
≫ 𝑝𝑟𝑖𝑛𝑡𝑠𝑦𝑠_𝑠𝑒𝑟𝑖𝑒𝑠(𝑛𝑢𝑚, 𝑑𝑒𝑛)

Output:
Parallel Form
Given two system that are connected in parallel as shown in figure below, the overall
transfer function can be written as:
𝑁1 (𝑠) 𝑁2 (𝑠)
𝐺 (𝑠) = 𝐺1 (𝑠) + 𝐺2 (𝑠) = +
𝐷1 (𝑠) 𝐷2 (𝑠)
To illustrate, consider the given transfer functions in section 2.1 except that the blocks
are connected in parallel. The system can be reduced into a single transfer function by
simply using the MATLAB function parallel.

Using the same values for num1, den1, num2, den2, we can type
≫ [𝑛𝑢𝑚, 𝑑𝑒𝑛] = 𝑝𝑎𝑟𝑎𝑙𝑙𝑒𝑙 (𝑛𝑢𝑚1, 𝑑𝑒𝑛1, 𝑛𝑢𝑚2, 𝑑𝑒𝑛2)
≫ 𝑝𝑟𝑖𝑛𝑡𝑠𝑦𝑠_𝑝𝑎𝑟𝑎𝑙𝑙𝑒𝑙(𝑛𝑢𝑚, 𝑑𝑒𝑛)

Output:

Feedback Form
System such as shown in figure 3-3 contains feedback. The overall transfer function can
be written as follows:
𝐺1 (𝑠)
𝐻 (𝑠 ) =
1 + 𝐺1 (𝑠)𝐻1 (𝑠)

To reduce this into a single transfer function, we can use the MATLAB function
feedback. Let us consider the example in 2.1 by assuming that G1(s) = G1(s) and
H1(s) = G2(s). The overall transfer function can be obtained by:
≫ [𝑛𝑢𝑚, 𝑑𝑒𝑛] = 𝑓𝑒𝑒𝑑𝑏𝑎𝑐𝑘(𝑛𝑢𝑚1, 𝑑𝑒𝑛1, 𝑛𝑢𝑚2, 𝑑𝑒𝑛2)
≫ 𝑝𝑟𝑖𝑛𝑡𝑠𝑦𝑠_𝑓𝑒𝑒𝑑𝑏𝑎𝑐𝑘(𝑛𝑢𝑚, 𝑑𝑒𝑛)
Output:

Block Diagram Reduction of complicated system


System reduction in a very complicated system using the series, parallel, and feedback
function could be tedious. Instead we use the blkbuild and connect command. This can
be done by first numbering the transfer function blocks sequentially from one to the
number of blocks. nblocks defines the total number of blocks and bldblock converts
each block to an unconnected state-space representation.
The statement [A,B,C,D] = connect(a,b,c,d,q,iu,iy) connects up the blocks according to a
predefined matrix q that specifies the interconnections. The first element of each row of
the q matrix is the block number. The remaining elements indicate the source of the
block’s summing input. When the input to the summing junction is negative, the block
number is entered with a negative sign. The iu and iy are two row vectors indicating
retaining input and output blocks. Finally, to obtain the overall transfer function, use the
MATLAB function ss2tf.
Ex.

The following is the procedure to simplify the system shown in into its equivalent transfer
function.
Step 1. Number each blocks sequentially from 1 to the number of blocks like the figure
shown above.
Step 2. Enter the numerator and denominator polynomials of each block. Take note that
the numerator and denominator of ith block is defined by ni and di, respectively. For the
block diagram shown above, the numerator and denominator polynomials are as follows:
>> n1=1; d1=1;
>> n2=0.5; d2=1;
>> n3=4; d3=[1 4];
>> n4=1; d4=[1 2];
>> n5=1; d5=[1 3];
>> n6=2; d6=1;
>> n7=5; d7=1;
>> n8=1; d8=1;
Note : The order of the numerator polynomial must be less than the denominator
polynomial otherwise an error will occur in the script file “blkbuild”.
Step 3. Specify the total number of blocks. Use the variable “nblock”. Type the script file
“blkbuild” to build a block diagonal state space structure from a block diagram of transfer
functions. (For more details type help blkbuild)
>> nblocks=8;
>> blkbuild;
Step 4. Write a matrix that indicates the block diagram configurations. For the above
block diagram the matrix can be written as follows:
q=[10000
2 1 -6 -7 -8
32000
43000
54000
63000
74000
85000]
Step 5. Specify the input and output for the connected system. For the block diagram
above, the input is connected to the input of the first block and the output is connected
to the input of the 8th block.
>> iu = [1];
>> iy = [8];
Step 6. Type the statement [A,B,C,D] = connect(a,b,c,d,q,iu,iy). (Please type help
connect for more details).
Step 7. To convert the state space representation to transfer function, use the Matlab
function “ss2tf”.
Note: The overall transfer function is:
An easier approach is to make use of the series, parallel, and feedback functions:
≫ [𝑛𝑢𝑚1, 𝑑𝑒𝑛1] = 𝑓𝑒𝑒𝑑𝑏𝑎𝑐𝑘((2, [1 4]), 2,1);
≫ [𝑛𝑢𝑚2, 𝑑𝑒𝑛2] = 𝑠𝑒𝑟𝑖𝑒𝑠(𝑛𝑢𝑚1, 𝑑𝑒𝑛1, 1, [1 2]);
≫ [𝑛𝑢𝑚3, 𝑑𝑒𝑛3] = 𝑓𝑒𝑒𝑑𝑏𝑎𝑐𝑘 (𝑛𝑢𝑚2, 𝑑𝑒𝑛2, 5,1);
≫ [𝑛𝑢𝑚4, 𝑑𝑒𝑛34] = 𝑠𝑒𝑟𝑖𝑒𝑠(𝑛𝑢𝑚3, 𝑑𝑒𝑛3, 1, [1 3]);
≫ [𝑛𝑢𝑚, 𝑑𝑒𝑛] = 𝑓𝑒𝑒𝑑𝑏𝑎𝑐𝑘(𝑛𝑢𝑚4, 𝑑𝑒𝑛4, 1,1);
≫ 𝑝𝑟𝑖𝑛𝑡𝑠𝑦𝑠_𝑒𝑥(𝑛𝑢𝑚, 𝑑𝑒𝑛)

Output:

You might also like