]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/obsvf.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / obsvf.m
1 ## Copyright (C) 2010   Benjamin Fernandez 
2 ## Copyright (C) 2011   Lukas F. Reichlin
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{sysbar}, @var{T}, @var{K}] =} obsvf (@var{sys})
21 ## @deftypefnx{Function File} {[@var{sysbar}, @var{T}, @var{K}] =} obsvf (@var{sys}, @var{tol})
22 ## @deftypefnx{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} obsvf (@var{A}, @var{B}, @var{C})
23 ## @deftypefnx{Function File} {[@var{Abar}, @var{Bbar}, @var{Cbar}, @var{T}, @var{K}] =} obsvf (@var{A}, @var{B}, @var{C}, @var{TOL})
24 ## If Ob=obsv(A,C) has rank r <= n = SIZE(A,1), then there is a 
25 ## similarity transformation Tc such that To = [t1;t2] where t1 is c
26 ## and t2 is orthogonal to t1
27 ##
28 ## @example
29 ## @group
30 ## Abar = To \ A * To ,  Bbar = To \ B ,  Cbar = C * To
31 ## @end group
32 ## @end example
33 ## 
34 ## and the transformed system has the form
35 ##
36 ## @example
37 ## @group
38 ##        | Ao     0 |           | Bo  |
39 ## Abar = |----------|,   Bbar = | --- |,  Cbar = [Co | 0 ].
40 ##        | A21   Ano|           | Bno |
41 ## @end group
42 ## @end example
43 ##                                                      
44 ## where (Ao,Bo) is observable, and Co(sI-Ao)^(-1)Bo = C(sI-A)^(-1)B. And 
45 ## system is detectable if Ano has no eigenvalues in the right 
46 ## half plane. The last output K is a vector of length n containing the 
47 ## number of observable states.
48 ## @end deftypefn
49
50 ## Author: Benjamin Fernandez <benjas@benjas-laptop>
51 ## Created: 2010-05-02
52 ## Version: 0.1
53
54 function [ac, bc, cc, z, ncont] = obsvf (a, b = [], c, tol = [])
55
56   if (nargin < 1 || nargin > 4)
57     print_usage ();
58   endif
59   
60   if (isa (a, "lti"))
61     if (nargin > 2)
62       print_usage ();
63     endif
64     [ac, bc, cc] = ctrbf (a.', b);      # [sysbar, z, ncont] = ctrbf (sys.', tol);
65     ac = ac.';
66     z = ncont = [];
67   else
68     if (nargin < 3)
69       print_usage ();
70     endif
71     [ac, tmp, cc, z, ncont] = ctrbf (a.', c.', b.', tol);
72     ac = ac.';
73     bc = cc.';
74     cc = tmp.';
75   endif
76
77 endfunction