connect - Arbitrary interconnection of LTI models

Syntax

sysc = connect(sysa, sysb, ..., inputs, outputs) sysc = connect(sys,Q,inputs,outputs)

Description

sysc = connect(sysa, sysb, ..., inputs, outputs) sysc = connect(sys,Q,inputs,outputs)

connect constructs the aggregate model for a given block diagram interconnection of LTI models. You can specify the block diagram connectivity in two ways, name-based and index-based.

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) 

where inputs and outputs are the names of the block diagram external I/Os, specified as strings or cell arrays of strings.

Example

Given LTI models C and G, and referring to this block diagram,

you can construct the closed-loop transfer T from r to y as follows

C.InputName = e;  C.OutputName = u;
G.InputName = u;  G.OutputName = y;
Sum = ss([1,-1],'InputName',{'r','y'},'OutputName','e');
T = connect(G,G,Sum,'r','y')

Index-Based Interconnection

In this approach, first combine all LTI blocks into an aggregate, unconnected model blksys using append. Then construct a matrix Q where each row specifies one of the connections or summing junctions in terms of the input vector u and output vector y of blksys. For example, the row

[3 2 0 0]

indicates that y(2) feeds into u(3), while the row

[7 2 -15 6]

indicates that y(2)-y(15)+y(6) feeds into u(7). The aggregate model sys is then obtained by

sys = connect(blksys,Q,inputs,outputs) 

where inputs and outputs are index vectors into u and y selecting the block diagram external I/Os.

Example

You can construct the closed-loop model T for the block diagram above as follows:

blksys = append(C,G); 
% u = inputs to C,G.  y = outputs of C,G.
% Here y(1) feeds into u(2) and -y(2) feeds into u(1)
Q = [2 1; 1 -2]; 
% External I/Os: r drives u(1) and y is y(2)
T = connect(blksys,Q,1,2)

Since it is easy to make a mistake entering all the data required for a large model, be sure to verify your model in as many ways as you can. Here are some suggestions:

Delays

The connect function supports I/O and internal delays. See Time Delays for more information and examples.

Example

Consider the following block diagram

.

Given the matrices of the state-space model sys2

A = [ -9.0201  17.7791 
      -1.6943  3.2138 ];
B = [ -.5112  .5362
      -.002  -1.8470];
C = [ -3.2897  2.4544
      -13.5009  18.0745];
D = [-.5476  -.1410
    -.6459  .2958 ];

Define the three blocks as individual LTI models.

sys1 = tf(10,[1 5],'inputname','uc')
sys2 = ss(A,B,C,D,'inputname',{'u1' 'u2'},...
                    'outputname',{'y1' 'y2'})
sys3 = zpk(-1,-2,2)

Next append these blocks to form the unconnected model sys.

sys = append(sys1,sys2,sys3)

This produces the block-diagonal model

sys
 
a = 
                        x1           x2           x3           x4
           x1           -5            0            0            0
           x2            0      -9.0201       17.779            0
           x3            0      -1.6943       3.2138            0
           x4            0            0            0           -2
 
 
b = 
                        uc           u1           u2            ?
           x1            4            0            0            0
           x2            0      -0.5112       0.5362            0
           x3            0       -0.002       -1.847            0
           x4            0            0            0       1.4142


c = 
                        x1           x2           x3           x4
            ?          2.5            0            0            0
           y1            0      -3.2897       2.4544            0
           y2            0      -13.501       18.075            0
            ?            0            0            0      -1.4142
 
 
d = 
                        uc           u1           u2            ?
            ?            0            0            0            0
           y1            0      -0.5476       -0.141            0
           y2            0      -0.6459       0.2958            0
            ?            0            0            0            2
 
Continuous-time system.

Note that the ordering of the inputs and outputs is the same as the block ordering you chose. Unnamed inputs or outputs are denoted b.

To derive the overall block diagram model from sys, specify the interconnections and the external inputs and outputs. You need to connect outputs 1 and 4 into input 3 (u2), and output 3 (y2) into input 4. The interconnection matrix Q is therefore

Q = [3 1 -4
     4 3  0];

Note that the second row of Q has been padded with a trailing zero. The block diagram has two external inputs uc and u1 (inputs 1 and 2 of sys), and two external outputs y1 and y2 (outputs 2 and 3 of sys). Accordingly, set inputs and outputs as follows.

inputs = [1 2];
outputs = [2 3];

You can obtain a state-space model for the overall interconnection by typing

sysc = connect(sys,Q,inputs,outputs)

a = 
                        x1           x2           x3           x4
           x1           -5            0            0            0
           x2      0.84223     0.076636       5.6007      0.47644
           x3      -2.9012      -33.029       45.164      -1.6411
           x4      0.65708      -11.996        16.06      -1.6283
 
 
b = 
                        uc           u1
           x1            4            0
           x2            0    -0.076001
           x3            0      -1.5011
           x4            0     -0.57391
 
 
c = 
                        x1           x2           x3           x4
           y1     -0.22148      -5.6818       5.6568     -0.12529
           y2      0.46463      -8.4826       11.356      0.26283
 
 
d = 
                        uc           u1
           y1            0     -0.66204
           y2            0     -0.40582
 
Continuous-time system.

Note that the inputs and outputs are as desired.

References

[1] Edwards, J.W., "A Fortran Program for the Analysis of Linear Continuous and Sampled-Data Systems," NASA Report TM X56038, Dryden Research Center, 1976.

See Also

append, feedback, minreal, parallel, series, lft

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS