home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 10.ddi / CONTROL.DI$ / RIC.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  865 b   |  25 lines

  1. function [kerr,serr] = ric(a,b,q,r,k,s,n)
  2. %RIC    Riccati residual calculation.
  3. %    [Kerr,Serr] = RIC(A,B,Q,R,K,S) Computes the error in the solution
  4. %    to the Riccati equation.  Kerr is the error in the gain matrix
  5. %    and Serr is the residual error in the Riccati equation.
  6. %                  -1                           -1
  7. %        Kerr = K-R  B'S;  Serr = SA + A'S - SBR  B'S + Q
  8. %
  9. %    [Kerr,Serr] = RIC(A,B,Q,R,K,S,N) computes the error in the 
  10. %    solution to the Riccati equation with cross weighting term.
  11. %              -1                                    -1
  12. %    Kerr = K-R  (N'+B'S);  Serr = SA + A'S - (SB+N)R  (N'+B'S) + Q
  13. %
  14. %    See also: DRIC,ARE,LQE, and LQR.
  15.  
  16. %    Copyright (c) 1986-93 by the MathWorks, Inc.
  17.  
  18. if nargin == 7
  19.     serr = s*a + a'*s - (s*b+n)/r*(n'+b'*s) + q;
  20.     kerr = k - r\(n'+b'*s);
  21. else
  22.     serr = s*a+a'*s-s*b/r*b'*s+q;
  23.     kerr = k - r\b'*s;
  24. end
  25.