home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts / control / obsv.m < prev    next >
Encoding:
Text File  |  1999-12-15  |  1.8 KB  |  66 lines

  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 -*-
  20. ##@deftypefn {Function File } { @var{Qb} =} obsv (@var{sys}@{, @var{c}@})
  21. ## Build observability matrix
  22. ## @example
  23. ## @group
  24. ##      | C        |
  25. ##      | CA       |
  26. ## Qb = | CA^2     |
  27. ##      | ...      |
  28. ##      | CA^(n-1) |
  29. ## @end group
  30. ## @end example
  31. ## of a system data structure or the pair (A, C).
  32. ## 
  33. ## Note: @code{obsv()} forms the observability matrix.
  34. ## 
  35. ##        The numerical properties of is_observable()
  36. ##        are much better for observability tests.
  37. ## @end deftypefn
  38.  
  39. function Qb = obsv (sys, c)
  40.  
  41.   ## Written by Kai P. Mueller November 4, 1997
  42.   ## modified by
  43.  
  44.   if (nargin == 2)
  45.     a = sys;
  46.   elseif (nargin == 1 && is_struct(sys))
  47.     sysupdate(sys,"ss");
  48.     [a,b,c] = sys2ss(sys);
  49.   else
  50.     usage("obsv(sys [, c])")
  51.   endif
  52.  
  53.   if (!is_abcd(a,c'))
  54.     Qb = [];
  55.   else
  56.     ## no need to check dimensions, we trust is_abcd().
  57.     [na, ma] = size(a);
  58.     [nc, mc] = size(c);
  59.     Qb = zeros(na*nc, ma);
  60.     for i = 1:na
  61.       Qb((i-1)*nc+1:i*nc, :) = c;
  62.       c = c * a;
  63.     endfor
  64.   endif
  65. endfunction
  66.