comparison scripts/control/base/dlqe.m @ 3431:99ab64f4a09d

[project @ 2000-01-14 03:53:03 by jwe]
author jwe
date Fri, 14 Jan 2000 04:12:41 +0000
parents
children 9debe1be75a5
comparison
equal deleted inserted replaced
3430:65b3519ac3a1 3431:99ab64f4a09d
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{l}, @var{m}, @var{p}, @var{e}] =} dlqe (@var{a}, @var{g}, @var{c}, @var{sigw}, @var{sigv}, @var{z})
21 ## Construct the linear quadratic estimator (Kalman filter) for the
22 ## discrete time system
23 ## @iftex
24 ## @tex
25 ## $$
26 ## x_{k+1} = A x_k + B u_k + G w_k
27 ## $$
28 ## $$
29 ## y_k = C x_k + D u_k + w_k
30 ## $$
31 ## @end tex
32 ## @end iftex
33 ## @ifinfo
34 ##
35 ## @example
36 ## x[k+1] = A x[k] + B u[k] + G w[k]
37 ## y[k] = C x[k] + D u[k] + w[k]
38 ## @end example
39 ##
40 ## @end ifinfo
41 ## where @var{w}, @var{v} are zero-mean gaussian noise processes with
42 ## respective intensities @code{@var{sigw} = cov (@var{w}, @var{w})} and
43 ## @code{@var{sigv} = cov (@var{v}, @var{v})}.
44 ##
45 ## If specified, @var{z} is @code{cov (@var{w}, @var{v})}. Otherwise
46 ## @code{cov (@var{w}, @var{v}) = 0}.
47 ##
48 ## The observer structure is
49 ## @iftex
50 ## @tex
51 ## $$
52 ## z_{k+1} = A z_k + B u_k + k (y_k - C z_k - D u_k)
53 ## $$
54 ## @end tex
55 ## @end iftex
56 ## @ifinfo
57 ##
58 ## @example
59 ## z[k+1] = A z[k] + B u[k] + k (y[k] - C z[k] - D u[k])
60 ## @end example
61 ## @end ifinfo
62 ##
63 ## @noindent
64 ## The following values are returned:
65 ##
66 ## @table @var
67 ## @item l
68 ## The observer gain,
69 ## @iftex
70 ## @tex
71 ## $(A - ALC)$.
72 ## @end tex
73 ## @end iftex
74 ## @ifinfo
75 ## (@var{a} - @var{a}@var{l}@var{c}).
76 ## @end ifinfo
77 ## is stable.
78 ##
79 ## @item m
80 ## The Riccati equation solution.
81 ##
82 ## @item p
83 ## The estimate error covariance after the measurement update.
84 ##
85 ## @item e
86 ## The closed loop poles of
87 ## @iftex
88 ## @tex
89 ## $(A - ALC)$.
90 ## @end tex
91 ## @end iftex
92 ## @ifinfo
93 ## (@var{a} - @var{a}@var{l}@var{c}).
94 ## @end ifinfo
95 ## @end table
96 ## @end deftypefn
97
98 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu>
99 ## Created: August 1993
100 ## Modified for discrete time by R. Bruce Tenison (btenison@eng.auburn.edu)
101 ## October, 1993
102
103 function [l, m, p, e] = dlqe (a, g, c, sigw, sigv, s)
104
105 if (nargin != 5 && nargin != 6)
106 error ("dlqe: invalid number of arguments");
107 endif
108
109 ## The problem is dual to the regulator design, so transform to dlqr call.
110
111 if (nargin == 5)
112 [k, p, e] = dlqr (a', c', g*sigw*g', sigv);
113 m = p;
114 l = k';
115 else
116 [k, p, e] = dlqr (a', c', g*sigw*g', sigv, g*s);
117 m = p;
118 l = k';
119 a = a-g*t/sigv*c;
120 sigw = sigw-t/sigv;
121 endif
122
123 p = a\(m-g*sigw*g')/a';
124
125 endfunction