3431
|
1 ## Copyright (C) 1997 Kai P. Mueller |
|
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 -*- |
5016
|
20 ## @deftypefn {Function File} {} obsv (@var{sys}, @var{c}) |
|
21 ## @deftypefnx {Function File} {} obsv (@var{a}, @var{c}) |
|
22 ## Build observability matrix: |
|
23 ## @iftex |
|
24 ## @tex |
|
25 ## $$ Q_b = \left[ \matrix{ C \cr |
|
26 ## CA \cr |
|
27 ## CA^2 \cr |
|
28 ## \vdots \cr |
|
29 ## CA^{n-1} } \right ] $$ |
|
30 ## @end tex |
|
31 ## @end iftex |
|
32 ## @ifinfo |
3431
|
33 ## @example |
|
34 ## @group |
|
35 ## | C | |
|
36 ## | CA | |
|
37 ## Qb = | CA^2 | |
|
38 ## | ... | |
|
39 ## | CA^(n-1) | |
|
40 ## @end group |
|
41 ## @end example |
5016
|
42 ## @end ifinfo |
|
43 ## of a system data structure or the pair (@var{a}, @var{c}). |
3431
|
44 ## |
5016
|
45 ## The numerical properties of @command{is_observable} |
3431
|
46 ## are much better for observability tests. |
|
47 ## @end deftypefn |
|
48 |
|
49 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
50 ## Created: November 4, 1997 |
|
51 |
|
52 function Qb = obsv (sys, c) |
|
53 |
|
54 if (nargin == 2) |
|
55 a = sys; |
4030
|
56 elseif (nargin == 1 && isstruct(sys)) |
3431
|
57 sysupdate(sys,"ss"); |
|
58 [a,b,c] = sys2ss(sys); |
|
59 else |
|
60 usage("obsv(sys [, c])") |
|
61 endif |
|
62 |
|
63 if (!is_abcd(a,c')) |
|
64 Qb = []; |
|
65 else |
|
66 ## no need to check dimensions, we trust is_abcd(). |
|
67 [na, ma] = size(a); |
|
68 [nc, mc] = size(c); |
|
69 Qb = zeros(na*nc, ma); |
|
70 for i = 1:na |
|
71 Qb((i-1)*nc+1:i*nc, :) = c; |
|
72 c = c * a; |
|
73 endfor |
|
74 endif |
|
75 endfunction |