home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts / control / lqe.m < prev    next >
Encoding:
Text File  |  1999-12-15  |  2.6 KB  |  108 lines

  1. ## Copyright (C) 1993, 1994, 1995 Auburn University.  All Rights Reserved
  2. ## 
  3. ## This file is part of Octave.
  4. ## 
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by the
  7. ## Free Software Foundation; either version 2, or (at your option) any
  8. ## later version.
  9. ## 
  10. ## Octave is distributed in the hope that it will be useful, but WITHOUT
  11. ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. ## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13. ## for more details.
  14. ## 
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
  18.  
  19. ## -*- texinfo -*-
  20. ## @deftypefn {Function File} {[@var{k}, @var{p}, @var{e}] =} lqe (@var{a}, @var{g}, @var{c}, @var{sigw}, @var{sigv}, @var{z})
  21. ## Construct the linear quadratic estimator (Kalman filter) for the
  22. ## continuous time system
  23. ## @iftex
  24. ## @tex
  25. ## $$
  26. ##  {dx\over dt} = A x + B u
  27. ## $$
  28. ## $$
  29. ##  y = C x + D u
  30. ## $$
  31. ## @end tex
  32. ## @end iftex
  33. ## @ifinfo
  34. ## 
  35. ## @example
  36. ## dx
  37. ## -- = a x + b u
  38. ## dt
  39. ## 
  40. ## y = c x + d u
  41. ## @end example
  42. ## 
  43. ## @end ifinfo
  44. ## where @var{w} and @var{v} are zero-mean gaussian noise processes with
  45. ## respective intensities
  46. ## 
  47. ## @example
  48. ## sigw = cov (w, w)
  49. ## sigv = cov (v, v)
  50. ## @end example
  51. ## 
  52. ## The optional argument @var{z} is the cross-covariance
  53. ## @code{cov (@var{w}, @var{v})}.  If it is omitted,
  54. ## @code{cov (@var{w}, @var{v}) = 0} is assumed.
  55. ## 
  56. ## Observer structure is @code{dz/dt = A z + B u + k (y - C z - D u)}
  57. ## 
  58. ## The following values are returned:
  59. ## 
  60. ## @table @var
  61. ## @item k
  62. ## The observer gain,
  63. ## @iftex
  64. ## @tex
  65. ## $(A - K C)$
  66. ## @end tex
  67. ## @end iftex
  68. ## @ifinfo
  69. ## (@var{a} - @var{k}@var{c})
  70. ## @end ifinfo
  71. ## is stable.
  72. ## 
  73. ## @item p
  74. ## The solution of algebraic Riccati equation.
  75. ## 
  76. ## @item e
  77. ## The vector of closed loop poles of
  78. ## @iftex
  79. ## @tex
  80. ## $(A - K C)$.
  81. ## @end tex
  82. ## @end iftex
  83. ## @ifinfo
  84. ## (@var{a} - @var{k}@var{c}).
  85. ## @end ifinfo
  86. ## @end table
  87. ## @end deftypefn
  88.  
  89. function [k, p, e] = lqe (a, g, c, sigw, sigv, zz)
  90. ## Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993.
  91.  
  92.   if ( (nargin != 5) && (nargin != 6))
  93.     error ("lqe: invalid number of arguments");
  94.   endif
  95.  
  96. ## The problem is dual to the regulator design, so transform to lqr
  97. ## call.
  98.  
  99.   if (nargin == 5)
  100.     [k, p, e] = lqr (a', c', g*sigw*g', sigv);
  101.   else
  102.     [k, p, e] = lqr (a', c', g*sigw*g', sigv, g*zz);
  103.   endif
  104.  
  105.   k = k';
  106.  
  107. endfunction
  108.