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

  1. function [acp,bcp,ccp,dcp,acl,bcl,ccl,dcl,hinfo,ak,bk1,bk2,ck1,ck2,dk11,dk12,dk21,dk22]=dhinf(Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8,Z9,Z10,Z11,Z12,Z13,Z14)
  2.  
  3. %     << Discrete 4-block Optimal H-inf Controller (all solution formulae) >>
  4. %       (via Bilinear Transform, Safonov, Limebeer and Chiang, 1989 IJC)
  5. %    
  6. %   [SS_CP,SS_CL,HINFO,TSS_K]=DHINF(TSS_P,SS_U,VERBOSE) computes the
  7. %   discrete H-inf controller F(z) and the controller parameterization K(z)
  8. %   using the "loop-shifting formulae" of Safonov, Limebeer and Chiang
  9. %   (IJC, 1989) and Bilinear Transform.  Given any stable U(z) having inf-norm
  10. %   not greater than one, F(z) is formed by feeding back U(z) around K(z).
  11. %   Required inputs --
  12. %      Augmented plant P(z): TSS_P=MKSYS(A,B1,B2,C1,C2,D11,D12,D21,D22)
  13. %   Optional inputs --
  14. %          Stable contraction U(z): SS_U=MKSYS(AU,BU,CU,DU) (default: U=0)
  15. %          VERBOSE:  if  1,  a verbose display results (default),
  16. %                    if  0, HINF operates silently
  17. %   Output data: Controller F(z):        SS_CP=MKSYS(ACP,BCP,CCP,DCP)
  18. %                Closed-Loop Ty1u1(z):   SS_CL=MKSYS(ACL,BCL,CCL,DCL) 
  19. %                 hinfo = (hinflag,RHP_cl,lamps_max)
  20. %                "hinflag" is the H-Infinity existence flag in ASCII
  21. %                All-solutions controller parameterization K(z):
  22. %                     TSS_K=MKSYS(A,BK1,BK2,CK1,CK2,DK11,DK12,DK21,DK22)
  23. %   This file can also used as a script file by typing DHINF with input 
  24. %   variables (A,B1,B2,C1,C2,D11,D12,D21,D22) ready in the main workspace
  25. %   in which case the variables (ss_cp,ss_cl,acp,bcp,ccp,dcp,acl,bcl,ccl,
  26. %   dcl,hinfo) are returned in the main workspace.
  27.  
  28. % R. Y. Chiang & M. G. Safonov 9/18/1988
  29. % Copyright (c) 1988 by the MathWorks, Inc.
  30. % All Rights Reserved.
  31. % ------------------------------------------------------------------------
  32.  
  33. % COMMENT:  This function also supports the following format for
  34. % input and output data which is not described above.  Possible
  35. % alternative usages include the following:
  36. %     [ACP,BCP,CCP,DCP,ACP,BCL,CCL,DCL,HINFO,AK,BK1,BK2,CK1,CK2,DK11,DK12,...
  37. %          DK21,DK22]=DHINF(A,B1,B2,C1,C2,D11,D12,D21,D22,AU,BU,CU,DU,VERBOSE)
  38. %     [ACP,BCP,CCP,DCP,ACP,BCL,CCL,DCL,HINFO,AK,BK1,BK2,CK1,CK2,DK11,DK12,...
  39. %          DK21,DK22]=DHINF(A,B1,B2,C1,C2,D11,D12,D21,D22,VERBOSE)
  40. % In all cases, the input data for U(z) and for VERBOSE is optional with
  41. % defaults U(z)=0 and VERBOSE=1. If no output arguments are supplied the
  42. % variables (ss_cp,ss_cl,acp,bcp,ccp, dcp,acl,bcl,ccl,dcl) are automatically
  43. % returned in the main workspace.
  44.  
  45. %%%
  46. %
  47. % --------- Expand input arguments 
  48. %
  49. nag1 = nargin;
  50. nag2 = nargout;
  51. sysuflag=0;       % This flag will be set to one if U(s) data is input
  52.  
  53.    inargs='(A,B1,B2,C1,C2,D11,D12,D21,D22,AU,BU,CU,DU,disp_hinf)';
  54.    eval(mkargs(inargs,nag1,'tss,ss'))  % Get input args, NARGIN, and XSFLAG 
  55.    nag1=nargin; % NARGIN may have changed if U(s) is given as system SS_U 
  56.                 % or if plant is given is system TSS_P
  57.    disp('   - - - - Transform the Plant via Bilinear Trnasform - - - -')
  58.    [aa,bb,cc,dd] = bilin(A,[B1 B2],[C1;C2],[D11 D12;D21 D22],-1,'Tustin',2);
  59.    dimp = [size(A)*[1;0],size(B1)*[0;1],size(B2)*[0;1],size(C1)*[1;0],...
  60.            size(C2)*[1;0]];
  61.    [A,B1,B2,C1,C2,D11,D12,D21,D22] = asys2ss([aa bb;cc dd],dimp);
  62.    if nag1==9
  63.      % Case A,B1,B2,C1,C2,D11,D12,D21,D22
  64.      [acp,bcp,ccp,dcp,acl,bcl,ccl,dcl,hinfo,ak,bk1,bk2,ck1,ck2,...
  65.       dk11,dk12,dk21,dk22] = hinf(A,B1,B2,C1,C2,D11,D12,D21,D22);
  66.    elseif nag1==10   % If only 10 input args after expansion
  67.      % Case A,B1,B2,C1,C2,D11,D12,D21,D22,disp_hinf
  68.      disp_hinf=AU;
  69.      [acp,bcp,ccp,dcp,acl,bcl,ccl,dcl,hinfo,ak,bk1,bk2,ck1,ck2,...
  70.       dk11,dk12,dk21,dk22] = hinf(A,B1,B2,C1,C2,D11,D12,D21,D22,disp_hinf);
  71.    elseif nag1==13
  72.      % Case A,B1,B2,C1,C2,D11,D12,D21,D22,AU,BU,CU,DU
  73.      [acp,bcp,ccp,dcp,acl,bcl,ccl,dcl,hinfo,ak,bk1,bk2,ck1,ck2,...
  74.       dk11,dk12,dk21,dk22] = hinf(A,B1,B2,C1,C2,D11,D12,D21,D22,AU,BU,CU,DU);
  75.    elseif nag1==14
  76.      % Case A,B1,B2,C1,C2,D11,D12,D21,D22,AU,BU,CU,DU,disp_hinf
  77.      [acp,bcp,ccp,dcp,acl,bcl,ccl,dcl,hinfo,ak,bk1,bk2,ck1,ck2,...
  78.       dk11,dk12,dk21,dk22] = hinf(A,B1,B2,C1,C2,D11,D12,D21,D22,...
  79.                                   AU,BU,CU,DU,disp_hinf);
  80.    else
  81.      error('Incompatible number or type of input arguments')
  82.    end
  83.  
  84. %
  85. % ------- Convert the w-plane solution back to z-plane:
  86. %
  87. disp('   - - - - Transform the Controller via Bilinear Trnasform - - - -')
  88. [acp,bcp,ccp,dcp] = bilin(acp,bcp,ccp,dcp,1,'Tustin',2);
  89. [acl,bcl,ccl,dcl] = bilin(acl,bcl,ccl,dcl,1,'Tustin',2);
  90. [aak,bbk,cck,ddk] = bilin(ak,[bk1 bk2],[ck1;ck2],[dk11,dk12;dk21,dk22],...
  91.                     1,'Tustin',2);
  92. dimk = [size(ak)*[1;0],size(bk1)*[0;1],size(bk2)*[0;1],...
  93.         size(ck1)*[1;0],size(ck2)*[1;0]];                     
  94. [ak,bk1,bk2,ck1,ck2,dk11,dk12,dk21,dk22] = asys2ss([aak bbk;cck ddk],dimk);
  95. %
  96. % -------- Convert to system matrices:
  97. %
  98. if nag2 == 0
  99.    save hinf2 acp bcp ccp dcp acl bcl ccl dcl hinfo ak bk1 bk2...
  100.         ck1 ck2 dk11 dk12 dk21 dk22 
  101.    hinfload
  102.    acp = 'Controller: (acp,bcp,ccp,dcp); Cost: (acl,bcl,ccl,dcl); Test Info: hinfo';
  103.    delete hinf1.mat
  104.    delete hinf2.mat
  105. else
  106.    if xsflag
  107.      % Case     [SS_CP,SS_CL,HINFO,TSS_K]=HINF(TSS_P,SS_U,...)
  108.      acp=mksys(acp,bcp,ccp,dcp);
  109.      if nag2>1,
  110.            bcp=mksys(acl,bcl,ccl,dcl);
  111.            ccp=hinfo;
  112.            if nag2>3,
  113.              dcp=mksys(ak,bk1,bk2,ck1,ck2,dk11,dk12,dk21,dk22,'tss');
  114.            end
  115.      end
  116.    end
  117. end
  118. %
  119. % --------- End of DHINF.M  % RYC/MGS %
  120.