home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / control / lqe.m < prev    next >
Text File  |  1999-04-29  |  2KB  |  60 lines

  1. # Copyright (C) 1993, 1994, 1995 John W. Eaton
  2. # This file is part of Octave.
  3. # Octave is free software; you can redistribute it and/or modify it
  4. # under the terms of the GNU General Public License as published by the
  5. # Free Software Foundation; either version 2, or (at your option) any
  6. # later version.
  7. # Octave is distributed in the hope that it will be useful, but WITHOUT
  8. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  10. # for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with Octave; see the file COPYING.  If not, write to the Free
  13. # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  14.  
  15. function [k, p, e] = lqe (a, g, c, sigw, sigv, zz)
  16.  
  17. # Usage: [k, p, e] = lqe (A, G, C, SigW, SigV {,Z})
  18. #
  19. # Linear quadratic estimator (Kalman filter) design for the 
  20. # continuous time system
  21. #
  22. #   dx/dt = A x + B u + G w
  23. #       y = C x + D u + v
  24. #
  25. # where w, v are zero-mean gaussian noise processes with respective
  26. # intensities SigW = cov (w, w) and SigV = cov (v, v).
  27. #
  28. # Z (if specified) is cov(w,v); otherwise cov(w,v) = 0.
  29. #
  30. # Observer structure is dz/dt = A z + B u + k( y - C z - D u).
  31. #
  32. # Returns:
  33. #
  34. #   k = observer gain, (A - K C) is stable
  35. #   p = solution of algebraic Riccati equation
  36. #   e = closed loop poles of (A - K C)
  37.  
  38. # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993.
  39.  
  40.   if ( (nargin != 5) && (nargin != 6))
  41.     error ("lqe: invalid number of arguments");
  42.   endif
  43.  
  44. # The problem is dual to the regulator design, so transform to lqr
  45. # call.
  46.  
  47.   if (nargin == 5)
  48.     [k, p, e] = lqr (a', c', g*sigw*g', sigv);
  49.   else
  50.     [k, p, e] = lqr (a', c', g*sigw*g', sigv, g*zz);
  51.   endif
  52.  
  53.   k = k';
  54.  
  55. endfunction
  56.