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

  1. function [a,b1,b2,c1,c2,d11,d12,d21,d22]=sec2tss(sec,dim)
  2. % TSS_ = SEC2TSS(SEC) or TSS_ = SEC2TSS(SEC,DIM) or
  3. % [A,B1,B2,C1,C2,D11,D12,D21,D22] = SEC2TSS(SEC) or
  4. % [A,B1,B2,C1,C2,D11,D12,D21,D22] = SEC2TSS(SEC,DIM) or
  5. %
  6. % SEC2TSS is a subroutine used by SECTF for converting
  7. % constant sectors into general two-port dynamical sectors.
  8.  
  9. % R. Y. Chiang & M. G. Safonov 3/06/92
  10. % Copyright (c) 1992 by the MathWorks, Inc.
  11. % All Rights Reserved.
  12.  
  13. % SEC2TSS converts a constant sector specification SEC into the
  14. % general dynamical `tss' two-port state-space SYSTEM form
  15. %     TSS_=system([],[],[],[],[],SEC11,SEC12,SEC21,SEC22,'tss');
  16. % The following formats for the matrix SEC are handled:
  17. %  SECTOR INEQUALITY:     |  SEC =       | COMMENTS:  
  18. % ------------------------|-------------------------------------------
  19. %  <Y-AU,Y-BU> <0         |  [A,B]       |  A,B are scalars or
  20. %                         |  [A;B]       |  square DIMxDIM matrices
  21. % --------------------------------------------------------------------
  22. %  <Y-diag(A)U,Y-diag(B)U>|  [A',B']     |  A,B are vectors of
  23. %            <0           |  [A;B]       |  length DIM
  24. % --------------------------------------------------------------------
  25. % <SEC11*U+SEC12*BY,      |[SEC11 SEC12  |  SEC11,SEC12,SEC21,SEC22
  26. %    SEC21*U+SEC22*Y> < 0 | SEC21 SEC22] |  square DIMxDIM matrices
  27. % -------------------------------------------------------------------- 
  28. % If nargin==1, then DIM defaults to DIM=max(size(SEC))/2.
  29.  
  30.  
  31.  
  32. % Case SEC is already in `tss' SYSTEM form, pass
  33. % argument(s) to output and return:
  34.  
  35. if issystem(sec)
  36.   if issame(branch(sec,'ty'),'tss'),
  37.     if nargout<2,
  38.        a=sec;
  39.     else
  40.        [a,b1,b2,c1,c2,d11,d12,d21,d22]=branch(sec);
  41.     end
  42.     return
  43.   end
  44. end
  45.  
  46. [r,c]=size(sec);
  47.  
  48. % Default value of DIM:
  49. if nargin<2
  50.    dim=max([r,c])/2;
  51. end
  52. x1=1:dim;x2=dim+1:2*dim;
  53.  
  54.  
  55. % Initialize abflag=0; later set to 1 if sector is [a,b] form:
  56. abflag=0;
  57.  
  58. if min([r,c])==1 & max([r,c])==2  
  59. % Case of scalar a,b
  60.        d11=diag(sec(1)*ones(dim,1)); d12=-eye(dim);
  61.        d21=diag(sec(2)*ones(dim,1)); d22=-eye(dim);
  62.        abflag=1;
  63. elseif min([r,c])==1 & max([r,c])==2*dim, 
  64. % Case of vector SEC=[a;b] or SEC=[a',b'] 
  65.        d11=diag(sec(x1));d12=-eye(dim);
  66.        d21=diag(sec(x2));d22=-eye(dim);
  67.        abflag=1;
  68. elseif r==2 & c==2, 
  69. % Case of scalar SEC11,SEC12,SEC21,SEC22:
  70.        d11=sec(1,1)*eye(dim);  d12=sec(1,2)*eye(dim);
  71.        d21=sec(2,1)*eye(dim);  d22=sec(2,2)*eye(dim);
  72. elseif 2*r==c & r==dim
  73. % Case of SEC=[A;B] with A,B square matrices
  74.        d11=sec(x1,x1);         d12=-eye(dim);
  75.        d21=sec(x1,x2);         d22=-eye(dim);
  76.        abflag=1;
  77. elseif r==2*c & c==dim,
  78. % Case of SEC=[A,B] with A,B square matrices
  79.        d11=sec(x1,x1);         d12=-eye(dim);
  80.        d21=sec(x2,x1);         d22=-eye(dim);
  81.        abflag=1;
  82. elseif r==c & c==2*dim,
  83. % Case of SEC = [A,B;C,D] with A,B square matrices
  84.        d11=sec(x1,x1);         d12=sec(x1,x2);
  85.        d21=sec(x2,x1);         d22=sec(x2,x2);
  86. else          % Case of SEC with invalid dimenions
  87.   txt1='SIZE(SEC) is incompatible with DIM:';
  88.   txt2='try SEC=[A;B] with A and B either scalars, vectors of length DIM,';
  89.   txt3='   or square matrices of size DIMxDIM.';
  90.   cr= [13 10];   % carriage return and new line
  91.   error([txt1 cr txt2 cr txt3])
  92. end
  93.  
  94. % Correctly handle sectors with A or B + or - INF:
  95. if abflag,
  96.   if min(max(d11))==Inf,
  97.      % Case A=Inf
  98.      d11=(2*norm(d21)+1)*eye(dim); d12=zeros(dim,dim);
  99.   end   
  100.   if min(max(d21))==Inf,
  101.      % Case B=Inf
  102.      d21=(2*norm(d11)+1)*eye(dim); d22=zeros(dim,dim);
  103.   end
  104.   if max(min(d11))==-Inf,
  105.      % Case A=-Inf
  106.      d11=-(2*norm(d21)+1)*eye(dim); d12=zeros(dim,dim);
  107.   end
  108.   if max(min(d21))==-Inf,
  109.      % Case A=-Inf
  110.      d21=-(2*norm(d11)+1)*eye(dim); d22=zeros(dim,dim);
  111.   end
  112. end
  113.  
  114.  
  115. % Now add empty state-space a,b,c matrices:
  116. af=[]; bf1=[]; bf2=[]; cf1=[]; cf2=[]; nf=0;
  117. ag=[]; bg1=[]; bg2=[]; cg1=[]; cg2=[]; ng=0;
  118.  
  119. % If nargout<2 convert output to SYSTEM format:
  120. if nargout<2,  
  121.    at=mksys(at,bt1,bt2,ct1,ct2,dt11,dt12,dt21,dt22,'tss');
  122. end
  123.   
  124.  
  125. % ------------------- End of SEC2TSS.M -----------------RYC/MGS 03/06/92
  126.