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

  1. function [K,P,P1,P2] = lqrc(A,B,QRN,aretype)
  2. %
  3. % [K,P,P1,P2] = LQRC(A,B,QRN,ARETYPE) solves the Riccati equation and 
  4. %     produces the optimal LQR feedback gain K such that the feedback law
  5. %     u = -Kx minimizes the cost function:
  6. %
  7. %       J = 1/2 Integral { [x' u'] | Q  N | |x| } dt ; ( QRN := |Q  N| )
  8. %                                  | N' R | |u|        (        |N' R| )
  9. %                                           .
  10. %     subject to the constraint equation: x = Ax + Bu.
  11. %     Also returned is P, the steady-state solution to the ARE:
  12. %                      -1
  13. %        0 = A'P + PA - (PB+N)R  (B'P+N') + Q
  14. %
  15. %     In addition, it will calculate the residual of the ARE. If the 
  16. %     problem is ill-posed such that the residual is large or there 
  17. %     exists jw-axis closed loop poles, a warning message will be displyed.
  18. %
  19. %     aretype = 'eigen' --- solve Riccati via eigenstructure (default)
  20. %     aretype = 'Schur' --- solve Riccati via Schur method.
  21. %
  22.  
  23. % R. Y. Chiang & M. G. Safonov 8/85
  24. % Copyright (c) 1988 by the MathWorks, Inc.
  25. % All Rights Reserved.
  26. % ------------------------------------------------------------------------
  27. if nargin == 3
  28.    aretype = 'eigen';
  29. end
  30. %
  31. [n,n] = size(A);
  32. [Q,N,NT,R] = sys2ss(QRN,n);
  33. Q = Q - N/R*NT;
  34. A = A - B/R*NT;
  35. RR = B/R*B';
  36. [P1,P2,lamp,Perr,wellposed,P] = aresolv(A,Q,RR,aretype);
  37. K = R\(NT + B'*P);
  38. %
  39. % ------ End of LQRC.M ---- RYC/MGS %
  40.