]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/@tf/__sys_group__.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / @tf / __sys_group__.m
1 ## Copyright (C) 2009, 2012   Lukas F. Reichlin
2 ##
3 ## This file is part of LTI Syncope.
4 ##
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.
9 ##
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.
14 ##
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/>.
17
18 ## -*- texinfo -*-
19 ## Block diagonal concatenation of two TF models.
20 ## This file is part of the Model Abstraction Layer.
21 ## For internal use only.
22
23 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
24 ## Created: September 2009
25 ## Version: 0.2
26
27 function retsys = __sys_group__ (sys1, sys2)
28
29   if (! isa (sys1, "tf"))
30     sys1 = tf (sys1);
31   endif
32
33   if (! isa (sys2, "tf"))
34     sys2 = tf (sys2);
35   endif
36
37   retsys = tf ();
38
39   retsys.lti = __lti_group__ (sys1.lti, sys2.lti);
40
41   [p1, m1] = size (sys1);
42   [p2, m2] = size (sys2);
43
44   empty12 = tfpolyzeros (p1, m2);
45   empty21 = tfpolyzeros (p2, m1);
46
47   retsys.num = [sys1.num, empty12 ;
48                 empty21,  sys2.num];
49
50   empty12 = tfpolyones (p1, m2);
51   empty21 = tfpolyones (p2, m1);
52
53   retsys.den = [sys1.den, empty12 ;
54                 empty21,  sys2.den];
55
56   if (sys1.tfvar == sys2.tfvar)
57     retsys.tfvar = sys1.tfvar;
58   elseif (sys1.tfvar == "x")
59     retsys.tfvar = sys2.tfvar;
60   else
61     retsys.tfvar = sys1.tfvar;
62   endif
63
64   if (sys1.inv || sys2.inv)
65     retsys.inv = true;
66   endif
67
68 endfunction