home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 7.ddi / ROBUST.DI$ / SECTF.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  9.8 KB  |  286 lines

  1. function [ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22,at,bt1,bt2,ct1,ct2,dt11,dt12,dt21,dt22]=sectf(Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8,Z9,Z10,Z11,Z12,Z13,Z14,Z15,Z16,Z17,Z18,Z19,Z20,Z21,Z22,Z23,Z24,Z25,Z26,Z27);
  2. % [SYSG,SYST] = SECTF(SYSF,SECF,SECG); or
  3. % [AG,BG,CG,DG,AT,BT1,...,DT21,DT22]=SECTF(AF,BF,CF,DF,SECF,SECG); or
  4. % [AG,BG1,...,DG22,AT,BT1,...,DT21,DT22]=SECTF(AF,BF1,...,DF22,SECF,SECG);
  5. %
  6. % SECTF computes the sector transformed system G(s) such that I/O pairs
  7. % (Ug,Yg) of G(s) are in sector SECG if and only the corresponding M-vector
  8. % I/O pairs (Uf,Yf) of F(s) are in are in sector SECF.  Also computed is 
  9. % a linear fractional transformation T(s) such that SYSG = LFTF(SYST,SYSF).
  10. % INPUTS: SYSF -- A SYSTEM in either 'ss' or 'tss' form; or the
  11. %                 corresponding list of matrices AF,BF,CF,DF or
  12. %                 AF,BF1,BF2,CF1,CF2,DF11,DF12,DF21,DF22; if 'tss'
  13. %                 form then the sector transform is applied to (Uf1,Yf1).
  14. %   SECF,SECG  -- Sectors in one of the following forms:
  15. %         Form:                       Corresponding Sector:
  16. %         [A,B] or [A;B]              0> <Y-AU,Y-BU> 
  17. %         [A,B] or [A;B]              0> <Y-diag(A)U,Y-diag(B)U>
  18. %         [SEC11 SEC12;SEC21,SEC22]   0> <SEC11*U+SEC12*Y,SEC21*U+SEC222*Y>
  19. %   where A,B are scalars in [-Inf,Inf] or square MxM matrices or M-vectors;
  20. %   and SEC=[SEC11,SEC12;SEC21,SEC22] is either a matrix or a 'tss' SYSTEM 
  21. %   with either 1x1 (scalar) or MxM blocks SEC11,SEC12,SEC21,SEC22.
  22. % OUTPUTS:  SYSG -- G(s) in  same form as F(s) (e.g., 'ss' or 'tss' form)
  23. %           SYST -- T(s) in 'tss'form; or list of matrices AT,BT1,...,DT22.
  24. %
  25. % See also LFTF, SEC2TSS and MKSYS.
  26.  
  27.  
  28. % R. Y. Chiang & M. G. Safonov 7/1/87, 3/7/92
  29. % Copyright (c) 1988, 1992 by the MathWorks, Inc.
  30. % All Rights Reserved.
  31.  
  32. nag1=nargin;
  33. nag2=nargout;
  34. ssflag=0;
  35. secfflag=0;
  36. secgflag=0;
  37. sysflag=issystem(Z1);
  38.  
  39.  
  40. if nag1==3,
  41. % If SYSG is 'ss' statespace form, set SSFLAG; also verify NAG1 is valid:
  42.   if sysflag,
  43.     if ~issame(branch(Z1,'ty'),'tss'),  % If Z1 is not a 'tss', assume it is 'ss' (or will be converted to 'ss' by MKARGS)
  44.        ssflag=1;
  45.     end
  46.   else
  47.     error('First of 3 input arguments should be a SYSTEM')
  48.   end
  49. elseif nag1==6  | nag1==14 | nag1==22,
  50.   % G(s) in a,b,c,d form or 'ss' form
  51.   ssflag=1;
  52. elseif nag1==11 | nag1==19 | nag1==27,
  53.   % G(s) in a,b1,b2,c1,...,d21,d22 form or 'tss' form
  54.   ssflag=0;
  55. elseif nag1==5 
  56.   % Case of old  1988 version of sectf--> call sectf88.m:
  57.   [ag,bg1,bg2,cg1]=sectf88(Z1,Z2,Z3,Z4,Z5);
  58.   return
  59. elseif nag1==8,
  60.   % Case of old  1988 version of sectf--> call sectf88.m:
  61.   [ag,bg1,bg2,cg1]=sectf88(Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8);
  62.   return
  63. else
  64.   error('Number of input arguments must be either 3,5,6,8,11,14,19,22 or 27 (depending on data format)')
  65. end
  66.  
  67. % If nag1 is 11,14 or 19 and Z1 is not a system, then one and only one of the two arguments SECF and SECG is a 'tss'
  68. % Depending on SSFLAG  modify INARGS; then call MKARGS.M
  69.  
  70. if ssflag,
  71.    % INARGS for case in which SYSG is 'ss' state-space:
  72.    inargs='(a,b,c,d,af,bf1,bf2,cf1,cf2,df11,df12,df21,df22,ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22)';
  73.    eval(mkargs(inargs,nag1,'ss,tss'))       
  74. else
  75.    % INARGS for case in which SYSG is 'tss' two-port state-space:
  76.    inargs='(a,b1,b2,c1,c2,d11,d12,d21,d22,af,bf1,bf2,cf1,cf2,df11,df12,df21,df22,ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22)';
  77.    eval(mkargs(inargs,nag1,'tss'))
  78. end
  79.  
  80. nag3=nargin;  % Number of input arguments after expansion
  81.  
  82. % Now determine DIM of T(s) from SYSG:
  83. if ssflag,
  84.   d11=d;
  85. end
  86. dim = max(size(d11));
  87.  
  88. % Make sure F(s) is square:
  89. if dim ~= min(size(d11)),
  90.   error(['Your system (F(s) is non-square:' 13 10 '     Sector transformation is only defined for a square systems'])
  91. end
  92.  
  93. % If sectors SECG and SECF are not dynamical (i.e., if  af,bf1,...
  94. % df22,ag1,bg1,...,dg22 not specified in the input) determine
  95. % equivalent dynamical sectors using SEC2TSS:
  96. if nag3==6 | nag3==11,          % If  SECF and SECG were both not dynamical
  97.   secf=af;    % SECF is notation for SECF
  98.   secg=bf1;   % SECG is notation for SECG
  99.   % Now transform constant sectors SECF and SECG to standard
  100.   % dynamical two-port state space ('tss') form:
  101.   [af,bf1,bf2,cf1,cf2,df11,df12,df21,df22]=sec2tss(secf,dim);
  102.   [ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22]=sec2tss(secg,dim);
  103. elseif (nag3==14 | nag3==19)
  104.   txtf = ['secfflag=issystem(Z' nag1-1 ')'];
  105.   eval(txtf)
  106.   txtg = ['secgflag=issystem(Z' nag1 ')'];
  107.   eval(txtg)  
  108.   if secfflag | min(size(ag))<max(size(ag)) | max(size(ag))~=max(size(df22))
  109.   % sufficient conditions for SECG to be constant and SECF dynamical
  110.     secg=ag;
  111.     [ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22]=sec2tss(secg,dim);
  112.   elseif min(size(af))<max(size(af)) | secgflag
  113.   % sufficient conditions for SECF to be constant and SECG dynamical
  114.     dg22=ag                                     
  115.     dg21=df22    
  116.     dg12=df21;  
  117.     dg11=df12;
  118.     cg2=df11;
  119.     cg1=cf2;
  120.     bg2=cf1;
  121.     bg1=bf2;
  122.     ag=bf1;
  123.     secf=af;
  124.   else
  125.     error('Try specifying dynamical SECG or SECF in SYSTEM format')
  126.   end
  127. elseif ~(nag3==22 | nag3==27)
  128.   error('Incorrect number or type of input arguments')
  129. end
  130.  
  131. % Do some cursory checks on dimensional compatibility
  132. dimf=max(size(df11));
  133. dimg=max(size(dg11));   
  134. if min([dimf,dimg])==1,
  135.   dim=max([dimf,dimg]); % then determine the default value 
  136. elseif dimf==dimg,       % of DIM from SECF and SECG
  137.    dim=dimf;
  138. else
  139.   error('SECF and SECG must have compatible dimensions')
  140. end
  141.  
  142.  
  143.  
  144.  
  145. % Do some cursory dimensionality checks
  146. tempf=[size(df11),size(df12),size(df21),size(df22)];
  147. tempg=[size(dg11),size(dg12),size(dg21),size(dg22)];
  148. if min(tempf)~=max(tempf)
  149.    error('Something wrong with the dimensions of input SECF')
  150. end
  151. if min(tempg)~=max(tempg)
  152.    error('Something wrong with the dimensions of input SECG')
  153. end
  154. if nag3<19,
  155.   if dimf~=dimg & min([dimf,dimg])>1,
  156.      error('SECF and SECG I/O dimensions must be equal if greater than 2'),
  157.   end
  158. elseif nag3==19
  159.   if dimf~=dim & dimf>1,
  160.      error('SECF must have I/O dimension equal to either 1 or DIM')
  161.   end
  162.   if dimg~=dim & dimg>1,
  163.      error('SECG must have I/O dimension equal to either 1 or DIM')
  164.   end
  165. end
  166.  
  167. [m,junk]=size(d11);
  168. [nf,junk]=size(af);
  169. [ng,junk]=size(ag);
  170. nt=nf+ng;
  171.  
  172. % We now have the following variables needed to compute T(s),G(s):
  173. %   dim                  min([size(DG11),size(DF11])
  174. %   nf                   the state-dimension of the `tss' system SECF
  175. %   ng                   the state-dimension of the `tss' system SECG
  176. %   nt = nf +ng          the state-dimension of T(s)
  177. %   (a,b,c,d) or (a,b1,b2,c1,c2,d11,d12,d21,d22);   from SS_1 or TSS_1
  178. %   af,bf1,bf2,cf1,cf2,df11,df12,df21,df22,'tss';   from SECF
  179. %   ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22,'tss';   from SEC2
  180. % Further all of the `d' matrices are square and of size mxm
  181. % and af is (nf)x(nf) and ag is (ng)x(ng).
  182.  
  183. % Using the equality SECF*[uf;yf] - SECG*[ug;yg] = 0 we obtain
  184. % the linear equation array:
  185. %     xg       xf       ug      yf      yg     uf    
  186. %--------------------------------------------------
  187. % -Is+ag        0      bg1       0     bg2     0   = 0
  188. %      0   -Is+af        0     bf2       0    bf1  = 0
  189. %    cg1     -cf1     dg11   -df12    dg12  -df11  = 0
  190. %    cg2     -cf2     dg21   -df22    dg22  -df21  = 0
  191.  
  192. % Solving the above array for the state-space (AT,BT,CT,DT) of the 2Mx2M
  193. % transfer function T(s) from [ug;yf] to [yg;uf], and partitioning to 
  194. % obtain the two-port state-space (AT,BT1,BT2,CT1,CT2,DT11,DT12,DT21,DT22):
  195.  
  196. TEMP =[  dg12  -df11  
  197.          dg22  -df21 ];
  198.  
  199. if rank(TEMP)<2*dim,
  200.    error('Transform is ill-conditioned--try perturbing SECF or SECG')
  201. end
  202.  
  203. dt = -TEMP\[dg11,-df12;dg21,-df22];
  204.  
  205. % Partition DT:
  206. u1=1:dim;
  207. u2=dim+1:2*dim;
  208. dt11=dt(u1,u1);
  209. dt12=dt(u1,u2);
  210. dt21=dt(u2,u1);
  211. dt22=dt(u2,u2);
  212.  
  213. if nt>0,
  214.   % compute AT,BT,CT:
  215.   ct = -TEMP\[cg1, -cf1;cg2,  -cf2];
  216.   TEMP = diagmx(bg2,bf1);
  217.   at =  diagmx(ag,af)+ TEMP*ct;
  218.   bt =  diagmx(bg1,bf2) + TEMP*dt;
  219.  
  220.   % Partition  BT,CT
  221.   bt1=bt(:,u1);
  222.   bt2=bt(:,u2);
  223.   ct1=ct(u1,:);
  224.   ct2=ct(u2,:);
  225. else
  226.    at=[];  bt1=[];  bt2 =[];
  227.   ct1=[];
  228.   ct2=[];
  229. end
  230.  
  231. % Now if the system is SISO and DIM is greater than one,
  232. % compute a realization for
  233. %          T(s) = [T11(s)*eye(DIM) T12(s)*eye(DIM)
  234. %                  T21(s)*eye(DIM) T22(s)*eye(DIM)]
  235. if max(size(dt11))==1 & dim>1,
  236.   as =at ;   bs1 = bt1 ; bs2 =  bt2;
  237.   cs1=ct1;   ds11= dt11; ds12= dt12;
  238.   cs2=ct2;   ds21= dt21; ds22= dt22;
  239.      at =diagmx(as ,at ); bt1 =diagmx(bs1, bt1 ); bt2 =diagmx(bs2 ,bt2 );
  240.      ct1=diagmx(cs1,ct1); dt11=diagmx(ds11,dt11); dt12=diagmx(ds12,dt12);
  241.      ct2=diagmx(cs2,ct2); dt21=diagmx(ds21,dt21); dt22=diagmx(dt22,dt22);
  242.   end
  243. end
  244.  
  245.  
  246. % Compute G(s) = LFTF(T(s),F(s))
  247. % (This means overwriting values of ag,bg1,...,dg22)
  248.  
  249. if ssflag,
  250.   [ag,bg,cg,dg]=lftf(at,bt1,bt2,ct1,ct2,dt11,dt12,dt21,dt22,a,b,c,d);
  251.   if sysflag,  % If input F(s) was in SYSTEM form:
  252.     ag=mksys(ag,bg,cg,dg);
  253.     if nag2>1,         % if nargout==2, convert T(s) tp SYSTEM
  254.       bg1=mksys(at,bt1,bt2,ct1,ct2,dt11,dt12,dt21,dt22,'tss');
  255.     end
  256.   elseif nag2==4 | nag2==13 % Need to re-order outputs 
  257.     bg1=bg;
  258.     bg2=cg;
  259.     cg1=dg;
  260.     if nag2==13,
  261.       cg2 =at  ;
  262.       dg11=bt1 ;
  263.       dg12=bt2 ;
  264.       dg21=ct1 ;
  265.       dg22=ct2 ;
  266.       at  =dt11;
  267.       bt1 =dt12;
  268.       bt2 =dt21;
  269.       ct1 =dt22;
  270.     end
  271.   else
  272.     error('Number of output arguments should be 1,2,4,or13')
  273.   end
  274. else
  275.   [ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22]=...
  276.    lftf(at,bt1,bt2,ct1,ct2,dt11,dt12,dt21,dt22,a,b1,b2,c1,c2,d11,d12,d21,d22);
  277.   if sysflag,  % If input F(s) was SYSTEM form:
  278.     ag=mksys(ag,bg1,bg2,cg1,cg2,dg11,dg12,dg21,dg22,'tss');
  279.   if nag2>1,         % if nargout==2, convert T(s) tp SYSTEM
  280.     bg1=mksys(at,bt1,bt2,ct1,ct2,dt11,dt12,dt21,dt22,'tss');
  281.   end
  282.   end
  283. end
  284.  
  285.  
  286. % ----------- End of SECTF.M --------RYC/MGS 1988 (REV. 03/06/92)