7017
|
1 ## Copyright (C) 1996, 2000, 2002, 2004, 2005, 2006, 2007 |
|
2 ## Auburn University. All rights reserved. |
3433
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3433
|
10 ## |
7016
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
3433
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3433
|
19 |
|
20 ## -*- texinfo -*- |
3882
|
21 ## @deftypefn {Function File} {} starp (@var{P}, @var{K}, @var{ny}, @var{nu}) |
3433
|
22 ## |
|
23 ## Redheffer star product or upper/lower LFT, respectively. |
5016
|
24 ## @example |
|
25 ## @group |
3433
|
26 ## |
|
27 ## +-------+ |
|
28 ## --------->| |---------> |
|
29 ## | P | |
|
30 ## +--->| |---+ ny |
|
31 ## | +-------+ | |
|
32 ## +-------------------+ |
|
33 ## | | |
|
34 ## +----------------+ | |
|
35 ## | | |
|
36 ## | +-------+ | |
|
37 ## +--->| |------+ nu |
|
38 ## | K | |
|
39 ## --------->| |---------> |
|
40 ## +-------+ |
5016
|
41 ## @end group |
|
42 ## @end example |
|
43 ## If @var{ny} and @var{nu} ``consume'' all inputs and outputs of |
|
44 ## @var{K} then the result is a lower fractional transformation. |
|
45 ## If @var{ny} and @var{nu} ``consume'' all inputs and outputs of |
|
46 ## @var{P} then the result is an upper fractional transformation. |
3433
|
47 ## |
5016
|
48 ## @var{ny} and/or @var{nu} may be negative (i.e. negative feedback). |
3433
|
49 ## @end deftypefn |
|
50 |
|
51 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
52 ## Created: May 1998 |
|
53 |
|
54 function sys = starp (P, K, ny, nu); |
|
55 |
7136
|
56 if (nargin != 2 && nargin != 4) |
6046
|
57 print_usage (); |
3433
|
58 endif |
7136
|
59 if (! isstruct (P)) |
|
60 error ("---> P must be in system data structure"); |
3433
|
61 endif |
7136
|
62 if (! isstruct (K)) |
|
63 error ("---> K must be in system data structure"); |
3433
|
64 endif |
|
65 |
7136
|
66 P = sysupdate (P, "ss"); |
|
67 [n, nz, mp, pp] = sysdimensions (P); |
3433
|
68 np = n + nz; |
7136
|
69 K = sysupdate (K, "ss"); |
|
70 [n, nz, mk, pk] = sysdimensions (K); |
3433
|
71 nk = n + nz; |
|
72 ny_sign = 1; |
|
73 nu_sign = 1; |
|
74 if (nargin == 2) |
|
75 ## perform a LFT of P and K (upper or lower) |
7136
|
76 ny = min ([pp, mk]); |
|
77 nu = min ([pk, mp]); |
3433
|
78 else |
|
79 if (ny < 0) |
|
80 ny = -ny; |
|
81 ny_sign = -1; |
|
82 endif |
|
83 if (nu < 0) |
|
84 nu = -nu; |
|
85 nu_sign = -1; |
|
86 endif |
|
87 endif |
|
88 if (ny > pp) |
7136
|
89 error ("---> P has not enough outputs."); |
3433
|
90 endif |
|
91 if (nu > mp) |
7136
|
92 error ("---> P has not enough inputs."); |
3433
|
93 endif |
|
94 if (ny > mk) |
7136
|
95 error ("---> K has not enough inputs."); |
3433
|
96 endif |
|
97 if (nu > pk) |
7136
|
98 error ("---> K has not enough outputs."); |
3433
|
99 endif |
|
100 nwp = mp - nu; |
|
101 nzp = pp - ny; |
|
102 nwk = mk - ny; |
|
103 nzk = pk - nu; |
7136
|
104 if (nwp + nwk < 1) |
|
105 error ("---> no inputs left for star product."); |
3433
|
106 endif |
7136
|
107 if (nzp + nzk < 1) |
|
108 error ("---> no outputs left for star product."); |
3433
|
109 endif |
|
110 |
|
111 ## checks done, form sys |
7136
|
112 if (nzp) |
|
113 Olst = 1:nzp; |
|
114 endif |
|
115 if (nzk) |
|
116 Olst = [Olst, pp+nu+1:pp+pk]; |
|
117 endif |
|
118 if (nwp) |
|
119 Ilst = 1:nwp; |
|
120 endif |
|
121 if (nwk) |
|
122 Ilst = [Ilst, mp+ny+1:mp+mk]; |
|
123 endif |
|
124 Clst = zeros (ny+nu, 2); |
3433
|
125 for ii = 1:nu |
|
126 Clst(ii,:) = [nwp+ii, nu_sign*(pp+ii)]; |
|
127 endfor |
|
128 for ii = 1:ny |
|
129 Clst(nu+ii,:) = [mp+ii, ny_sign*(nzp+ii)]; |
|
130 endfor |
7136
|
131 sys = buildssic (Clst, [], Olst, Ilst, P, K); |
3433
|
132 |
|
133 endfunction |