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 |
|
56 if((nargin != 2) && (nargin != 4)) |
6046
|
57 print_usage (); |
3433
|
58 endif |
4030
|
59 if (!isstruct(P)) |
3433
|
60 error("---> P must be in system data structure"); |
|
61 endif |
4030
|
62 if (!isstruct(K)) |
3433
|
63 error("---> K must be in system data structure"); |
|
64 endif |
|
65 |
|
66 P = sysupdate(P, "ss"); |
|
67 [n, nz, mp, pp] = sysdimensions(P); |
|
68 np = n + nz; |
|
69 K = sysupdate(K, "ss"); |
|
70 [n, nz, mk, pk] = sysdimensions(K); |
|
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) |
|
76 ny = min([pp, mk]); |
|
77 nu = min([pk, mp]); |
|
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) |
|
89 error("---> P has not enough outputs."); |
|
90 endif |
|
91 if (nu > mp) |
|
92 error("---> P has not enough inputs."); |
|
93 endif |
|
94 if (ny > mk) |
|
95 error("---> K has not enough inputs."); |
|
96 endif |
|
97 if (nu > pk) |
|
98 error("---> K has not enough outputs."); |
|
99 endif |
|
100 nwp = mp - nu; |
|
101 nzp = pp - ny; |
|
102 nwk = mk - ny; |
|
103 nzk = pk - nu; |
|
104 if ((nwp + nwk) < 1) |
|
105 error("---> no inputs left for star product."); |
|
106 endif |
|
107 if ((nzp + nzk) < 1) |
|
108 error("---> no outputs left for star product."); |
|
109 endif |
|
110 |
|
111 ## checks done, form sys |
|
112 if (nzp) Olst = [1:nzp]; endif |
|
113 if (nzk) Olst = [Olst, pp+nu+1:pp+pk]; endif |
|
114 if (nwp) Ilst = [1:nwp]; endif |
|
115 if (nwk) Ilst = [Ilst, mp+ny+1:mp+mk]; endif |
|
116 Clst = zeros(ny+nu,2); |
|
117 for ii = 1:nu |
|
118 Clst(ii,:) = [nwp+ii, nu_sign*(pp+ii)]; |
|
119 endfor |
|
120 for ii = 1:ny |
|
121 Clst(nu+ii,:) = [mp+ii, ny_sign*(nzp+ii)]; |
|
122 endfor |
|
123 sys = buildssic(Clst,[],Olst,Ilst,P,K); |
|
124 |
|
125 endfunction |