@lti/connect
Function File: csys = connect (sys1, sys2, …, sysN, in, out)
Function File: csys = connect (sys, cm, in, out)
Name-based or index-based interconnections between the outputs and inputs of LTI models.
Inputs
[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
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