@lti/connect
Name-based or index-based interconnections between the outputs and inputs of LTI models.
Inputs
LTI models to be connected by named-based connection. The properties ’inname’ and ’outname’ of each model should be set according to the desired input-output connections.
LTI model where the outputs are connected to the inputs by index-based connection.
For name-based interconnections, string or cell of strings containing the names of the inputs to be kept. The names must be part of the properties ’ingroup’ or ’inname’. For index-based interconnections, vector containing the indices of the inputs to be kept.
For name-based interconnections, string or cell of strings containing the names of the outputs to be kept. The names must be part of the properties ’outgroup’ or ’outname’. For index-based interconnections, vector containing the indices of the outputs to be kept.
Connection matrix (not name-based). Each row of the matrix represents a summing junction. The first column holds the indices of the inputs to be summed with outputs of the subsequent columns. The output indices can be negative, if the output is to be substracted, or zero. For example, the row
[2 0 3 -4 0] |
or
[2 -4 3] |
will sum input u(2) with outputs y(3) and y(4) as
u(2) + y(3) - y(4). |
If several systems are cinnected as in the name-based case, they have
to be stacked by append
before using connect
.
Outputs
Resulting interconnected system with outputs out and inputs in.
Example
Consider the control loop with reference r, disturbances d1, d2 and an additional output which represents the output of the controller
d1 --+ d2 --+ | | e +--------+ v u +--------+ v r --->o---->| K(s) |--+->o---->| G(s) |--->o--+----> y ^ - +--------+ | +--------+ | | | | | +------------------------------> yc | | +-------------------------------------------+ |
Name-based interconnections:
G.inname = 'u'; G.outname = 'y1'; K.inname = 'e'; K.outname = 'yc'; s1 = sumblk ('e = r - y'); s2 = sumblk ('u = yc + d1'); s3 = sumblk ('y = y1 + d2'); in = {'r', 'd1', 'd2'}; out = {'y', 'yc'}; G_cl1 = tf (connect (K, G, s1, s2, s3, in, out)) |
Index-based interconnections (without changing G
and K
):
G1 = tf (1); # static gains with r, d1, d2, y as outputs G_all = append (G1, G1, G1, K, G, G1); cm = [4, 1, -6; 5, 4, 2; 6, 5, 3]; in = [1, 2, 3]; out = [6, 4]; G_cl2 = connect (G_all, cm, in, out) |
Index-based interconnections (changing G
and K
):
[A,B,C,D] = ssdata(K); K = ss (A, [B -B], C, [D -D]); # compare s1 above [A,B,C,D] = ssdata(G); G = ss (A, [B B 0*B], C, [D D 1]); # compare s2 and s3 above G_all = append (K, G); cm = [2, 2; 3, 1]; in = [1, 3, 5]; out = [2, 1]; G_cl3 = tf (connect (G_all, cm, in, out)) |
Source Code: @lti/connect