home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 2.ddi / MUTOOLS2.DI$ / HINF_GAM.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  3.2 KB  |  129 lines

  1. %    [xinf,yinf,f,h,fail,hamx,hamy,hxmin,hymin] = 
  2. %          hinf_gam(p,nmeas,ncon,epr,gam,imethd);
  3. %
  4. %    solve the hamiltonian for xinf and yinf for the hinf program.
  5.  
  6. function [xinf,yinf,f,h,fail,hamx,hamy,hxmin,hymin] = ...
  7.                        hinf_gam(p,nmeas,ncon,epr,gam,imethd);
  8.  
  9. [a,bp,cp,dp,b1,b2,c1,c2,d11,d12,d21,d22,ndata] = hinf_sp(p,nmeas,ncon);
  10.  fail = 0;
  11.  np = max(size(a)); 
  12.  np1 = ndata(1);
  13.  np2 = ndata(2);
  14.  nm1 = ndata(3);
  15.  nm2 = ndata(4);
  16. %
  17. %  form r and rbar
  18. %
  19.  d1dot = [d11,d12];
  20.  r = zeros(nm1+nm2,nm1+nm2);
  21.  r(1:nm1,1:nm1) = -gam*gam*eye(nm1);
  22.  r = r+d1dot'*d1dot;
  23.  ddot1 = [d11;d21];
  24.  rbar = zeros(np1+np2,np1+np2);
  25.  rbar(1:np1,1:np1) = -gam*gam*eye(np1);
  26.  rbar = rbar+ddot1*ddot1';
  27. %
  28. % form hamiltonian hamx for xinf
  29. %
  30.  dum = ([bp;-c1'*d1dot]/r)*[d1dot'*c1,bp'];
  31.  hamx = [a,0*a;-c1'*c1,-a']-dum;
  32.  if imethd == 1
  33. %
  34. % solve the Riccati equation using eigenvalue decomposition
  35.    [x1,x2,fail,hxmin] = ric_eig(hamx,epr);
  36.     if fail == 1,
  37. %     fprintf(' ric(x) has jw axis eigs ');
  38.     else
  39. % really should check the condition number of x1 before doing this
  40. %  but the MATLAB `cond' command has problems
  41.      xinf = real(x2/x1);
  42. %     if max(eig(xinf)) == Inf | min(eig(xinf)) == -Inf
  43.      if any(any(~finite(xinf)))
  44.        fail = 1;
  45.        xinf = [];  
  46.      end
  47.    end
  48.  elseif imethd == 2
  49. %
  50. % solve the Riccati equation using real schur decomposition
  51. %
  52.    [x1,x2,fail,hxmin] = ric_schr(hamx,epr);
  53.     if fail == 1 | fail == 3
  54. %     fprintf(' ric(x) has jw axis eigs ');
  55.      xinf = [];
  56.      fail = 1;
  57.     elseif fail == 2 
  58. %     fprintf(' ric(x) unequal number of pos and neg eigenvalues')
  59.      xinf = [];
  60.      fail = 1;
  61.     else
  62.      xinf = real(x2/x1);
  63. %     if max(eig(xinf)) == Inf | min(eig(xinf)) == -Inf
  64.      if any(any(~finite(xinf)))
  65.        fail = 1;
  66.        xinf = [];  
  67.      end
  68.    end
  69. else
  70.    error('type of solution method is invalid')
  71.    return
  72.  end
  73. %
  74. %  form hamiltonian hamy for yinf
  75. %
  76.  dum = ([cp';-b1*ddot1']/rbar)*[ddot1*b1',cp];
  77.  hamy = [a',0*a;-b1*b1',-a]-dum;
  78.  if imethd == 1
  79. %
  80. % solve the Riccati equation using eigenvalue decomposition
  81.    [y1,y2,fail1,hymin] = ric_eig(hamy,epr);
  82.     if fail1 == 1,
  83. %     fprintf(' ric(y) has jw axis eigs ');
  84.     else
  85.      yinf = real(y2/y1);
  86. %     if max(eig(yinf)) == Inf | min(eig(yinf)) == -Inf
  87.      if any(any(~finite(yinf)))
  88.        fail = 1;
  89.        yinf = [];  
  90.      end
  91.     end
  92.  elseif imethd == 2
  93. %
  94. % solve the Riccati equation using real schur decomposition
  95. %
  96.    [y1,y2,fail1,hymin] = ric_schr(hamy,epr);
  97.     if fail1 == 1 | fail1 == 3
  98. %     fprintf(' ric(y) has jw axis eigs ');
  99.      xinf = [];
  100.      fail1 = 1;
  101.     elseif fail1 == 2 
  102. %    fprintf(' ric(y) unequal number of pos and neg eigenvalues')
  103.      xinf = [];
  104.      fail1 = 1;
  105.     else
  106.      yinf = real(y2/y1);
  107. %     if max(eig(yinf)) == Inf | min(eig(yinf)) == -Inf
  108.      if any(any(~finite(yinf)))
  109.        fail = 1;
  110.        yinf = [];  
  111.      end
  112.     end
  113.  end
  114. %
  115. %  form f, h, and their submatrices
  116. %
  117.  fail = fail | fail1;
  118.  if fail == 1
  119.    f = [];
  120.    h = [];
  121.  else
  122.    f = -r\(d1dot'*c1+bp'*xinf);
  123.    h = -(b1*ddot1'+yinf*cp')/rbar;
  124.  end
  125. %
  126. % Copyright MUSYN INC 1991,  All Rights Reserved
  127.