2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License 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 |
|
18 ## 02111-1307, USA. |
245
|
19 |
2311
|
20 ## Usage: [k, p, e] = lqe (A, G, C, SigW, SigV {,Z}) |
|
21 ## |
2325
|
22 ## Linear quadratic estimator (Kalman filter) design for the |
2311
|
23 ## continuous time system |
|
24 ## |
|
25 ## dx/dt = A x + B u + G w |
|
26 ## y = C x + D u + v |
|
27 ## |
|
28 ## where w, v are zero-mean gaussian noise processes with respective |
|
29 ## intensities SigW = cov (w, w) and SigV = cov (v, v). |
|
30 ## |
|
31 ## Z (if specified) is cov(w,v); otherwise cov(w,v) = 0. |
|
32 ## |
|
33 ## Observer structure is dz/dt = A z + B u + k( y - C z - D u). |
|
34 ## |
|
35 ## Returns: |
|
36 ## |
|
37 ## k = observer gain, (A - K C) is stable |
|
38 ## p = solution of algebraic Riccati equation |
|
39 ## e = closed loop poles of (A - K C) |
76
|
40 |
2312
|
41 ## Author: A. S. Hodel <scotte@eng.auburn.edu> |
|
42 ## Created: August 1993 |
|
43 ## Adapted-By: jwe |
76
|
44 |
2312
|
45 function [k, p, e] = lqe (a, g, c, sigw, sigv, zz) |
76
|
46 |
|
47 if (nargin != 5 && nargin != 6) |
904
|
48 error ("lqe: invalid number of arguments"); |
76
|
49 endif |
|
50 |
2303
|
51 ## The problem is dual to the regulator design, so transform to lqr |
|
52 ## call. |
76
|
53 |
|
54 if (nargin == 5) |
|
55 [k, p, e] = lqr (a', c', g*sigw*g', sigv); |
|
56 else |
|
57 [k, p, e] = lqr (a', c', g*sigw*g', sigv, g*zz); |
|
58 endif |
|
59 |
414
|
60 k = k'; |
|
61 |
76
|
62 endfunction |