3213
|
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton |
|
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, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
18 |
|
19 function [l, m, p, e] = dlqe (a, g, c, sigw, sigv, s) |
245
|
20 |
3213
|
21 # Usage: [l, m, p, e] = dlqe (A, G, C, SigW, SigV {,S}) |
|
22 # |
|
23 # Linear quadratic estimator (Kalman filter) design for the |
|
24 # discrete time system |
|
25 # |
|
26 # x[k+1] = A x[k] + B u[k] + G w[k] |
|
27 # y[k] = C x[k] + D u[k] + w[k] |
|
28 # |
|
29 # where w, v are zero-mean gaussian noise processes with respective |
|
30 # intensities SigW = cov (w, w) and SigV = cov (v, v). |
|
31 # |
|
32 # S (if specified) is cov(w,v); otherwise cov(w,v) = 0. |
|
33 # |
|
34 # Observer structure is |
|
35 # z[k+1] = A z[k] + B u[k] + k(y[k] - C z[k] - D u[k]). |
|
36 # |
|
37 # Returns: |
|
38 # |
|
39 # l = observer gain, (A - L C) is stable |
|
40 # m = Ricatti equation solution |
|
41 # p = the estimate error covariance after the measurement update |
|
42 # e = closed loop poles of (A - L C) |
201
|
43 |
3213
|
44 # Written by A. S. Hodel (scotte@eng.auburn.edu) August, 1993. |
|
45 # Modified for discrete time by R. Bruce Tenison (btenison@eng.auburn.edu) |
|
46 # October, 1993 |
201
|
47 |
|
48 if (nargin != 5 && nargin != 6) |
904
|
49 error ("dlqe: invalid number of arguments"); |
201
|
50 endif |
|
51 |
3213
|
52 # The problem is dual to the regulator design, so transform to dlqr call. |
201
|
53 |
|
54 if (nargin == 5) |
|
55 [k, p, e] = dlqr (a', c', g*sigw*g', sigv); |
3213
|
56 m = p; |
|
57 l = k'; |
201
|
58 else |
3213
|
59 [k, p, e] = dlqr (a', c', g*sigw*g', sigv, g*s); |
|
60 m = p; |
|
61 l = k'; |
201
|
62 a = a-g*t/sigv*c; |
1002
|
63 sigw = sigw-t/sigv; |
201
|
64 endif |
|
65 |
|
66 p = a\(m-g*sigw*g')/a'; |
|
67 |
|
68 endfunction |