1 ## Copyright (C) 2009, 2010 Lukas F. Reichlin
3 ## This file is part of LTI Syncope.
5 ## LTI Syncope is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, either version 3 of the License, or
8 ## (at your option) any later version.
10 ## LTI Syncope is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with LTI Syncope. If not, see <http://www.gnu.org/licenses/>.
19 ## @deftypefn {Function File} {@var{retsys} =} __sys_connect__ (@var{sys}, @var{M})
20 ## This function is part of the Model Abstraction Layer. No argument checking.
21 ## For internal use only.
24 ## Problem: Solve the system equations of
26 ## E x(t) = A x(t) + B e(t)
28 ## y(t) = C x(t) + D e(t)
30 ## e(t) = u(t) + M y(t)
34 ## K x(t) = F x(t) + G u(t)
36 ## y(t) = H x(t) + J u(t)
38 ## Solution: Laplace Transformation
39 ## E s X(s) = A X(s) + B U(s) + B M Y(s) [1]
41 ## Y(s) = C X(s) + D U(s) + D M Y(s) [2]
44 ## Y(s) = [I - D M]^(-1) C X(s) + [I - D M]^(-1) D U(s)
46 ## substitute Z = [I - D M]^(-1)
47 ## Y(s) = Z C X(s) + Z D U(s) [3]
49 ## insert [3] in [1], solve for X(s)
50 ## X(s) = [s E - (A + B M Z C)]^(-1) (B + B M Z D) U(s) [4]
52 ## inserting [4] in [3] finally yields
53 ## Y(s) = Z C [s E - (A + B M Z C)]^(-1) (B + B M Z D) U(s) + Z D U(s)
54 ## \ / | \_____ _____/ \_____ _____/ \ /
60 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
61 ## Created: September 2009
64 function sys = __sys_connect__ (sys, m)
71 z = eye (rows (d)) - d*m;
73 if (rcond (z) < eps) # check for singularity
74 error ("ss: sys_connect: (I - D*M) singular");
79 sys.a = a + b*m*z*c; # F
80 sys.b = b + b*m*z*d; # G
84 ## sys.e remains constant: [] for ss models, e for dss models