]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/obsv.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / obsv.m
1 ## Copyright (C) 2009, 2010   Lukas F. Reichlin
2 ## Copyright (C) 2009 Luca Favatella <slackydeb@gmail.com>
3 ##
4 ## This file is part of LTI Syncope.
5 ##
6 ## LTI Syncope is free software: you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, either version 3 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## LTI Syncope is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {@var{ob} =} obsv (@var{sys})
21 ## @deftypefnx {Function File} {@var{ob} =} obsv (@var{a}, @var{c})
22 ## Return observability matrix.
23 ##
24 ## @strong{Inputs}
25 ## @table @var
26 ## @item sys
27 ## LTI model.
28 ## @item a
29 ## State transition matrix (n-by-n).
30 ## @item c
31 ## Measurement matrix (p-by-n).
32 ## @end table
33 ##
34 ## @strong{Outputs}
35 ## @table @var
36 ## @item ob
37 ## Observability matrix.
38 ## @end table
39 ##
40 ## @strong{Equation}
41 ## @iftex
42 ## @tex
43 ## $$ O_b = \\left[ \\matrix{  C       \\cr
44 ##                             CA    \\cr
45 ##                             CA^2  \\cr
46 ##                             \\vdots  \\cr
47 ##                             CA^{n-1} } \\right ] $$
48 ## @end tex
49 ## @end iftex
50 ## @ifnottex
51 ## @example
52 ## @group
53 ##      | C        |
54 ##      | CA       |
55 ## Ob = | CA^2     |
56 ##      | ...      |
57 ##      | CA^(n-1) |
58 ## @end group
59 ## @end example
60 ## @end ifnottex
61 ## @end deftypefn
62
63 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
64 ## Created: October 2009
65 ## Version: 0.2
66
67 function ob = obsv (a, c)
68
69   if (nargin == 1)           # obsv (sys)
70     ob = ctrb (a.').';       # transpose is overloaded for lti models
71   elseif (nargin == 2)       # obsv (a, c)
72     ob = ctrb (a.', c.').';  # size checked inside
73   else
74     print_usage ();
75   endif
76
77 endfunction
78
79
80 %!assert (obsv ([1, 0; 0, -0.5], [8, 8]), [8, 8; 8, -4]);