home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / control / dlqe.m < prev    next >
Text File  |  1999-04-29  |  2KB  |  69 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 [l, m, p, e] = dlqe (a, g, c, sigw, sigv, s)
  16.  
  17. # Usage: [l, m, p, e] = dlqe (A, G, C, SigW, SigV {,S})
  18. #
  19. # Linear quadratic estimator (Kalman filter) design for the 
  20. # discrete time system
  21. #
  22. #  x[k+1] = A x[k] + B u[k] + G w[k]
  23. #    y[k] = C x[k] + D u[k] + w[k]
  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. # S (if specified) is cov(w,v); otherwise cov(w,v) = 0.
  29. #
  30. # Observer structure is 
  31. #     z[k+1] = A z[k] + B u[k] + k(y[k] - C z[k] - D u[k]).
  32. #
  33. # Returns:
  34. #
  35. #   l = observer gain, (A - L C) is stable
  36. #   m = Ricatti equation solution
  37. #   p = the estimate error covariance after the measurement update
  38. #   e = closed loop poles of (A - L C)
  39.  
  40. # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993.
  41. # Modified for discrete time by R. Bruce Tenison (btenison@eng.auburn.edu)
  42. # October, 1993
  43.  
  44.   if (nargin != 5 && nargin != 6)
  45.     error ("dlqe: invalid number of arguments");
  46.   endif
  47.  
  48. # The problem is dual to the regulator design, so transform to dlqr call.
  49.  
  50.   if (nargin == 5)
  51.     [k, p, e] = dlqr (a', c', g*sigw*g', sigv);
  52.     m = p;
  53.     l = k';
  54.   else
  55.     [k, p, e] = dlqr (a', c', g*sigw*g', sigv, g*s);
  56.     m = p;
  57.     l = k';
  58.     a = a-g*t/sigv*c;
  59.     sigw = sigw-t/sigv;
  60.   endif
  61.  
  62.   p = a\(m-g*sigw*g')/a';
  63.  
  64. endfunction
  65.