home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / control / obsv.m < prev    next >
Text File  |  1999-03-05  |  2KB  |  65 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. # Octave is distributed in the hope that it will be useful, but WITHOUT 
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  11. # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  12. # for more details.
  13. # You should have received a copy of the GNU General Public License 
  14. # along with Octave; see the file COPYING.  If not, write to the Free 
  15. # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  16.  
  17. function Qb = obsv(sys, c)
  18.   # ------------------------------------------------------
  19.   # Qb = obsv(sys [, c])
  20.   # Build observability matrix
  21.   #
  22.   #          +          +
  23.   #          | C        |
  24.   #          | CA       |
  25.   #     Qb = | CA^2     |
  26.   #          | ...      |
  27.   #          | CA^(n-1) |
  28.   #          +          +
  29.   #
  30.   # of a system data structure or the pair (A, C).
  31.   #
  32.   # Note: obsv() forms the observability matrix.
  33.   #       The numerical properties of is_observable()
  34.   #       are much better for observability tests.
  35.   # See also:  ctrb, is_observable, is_controllable
  36.   # ------------------------------------------------------
  37.  
  38.   # Written by Kai P. Mueller November 4, 1997
  39.   # modified by
  40.  
  41.   if (nargin == 2)
  42.     a = sys;
  43.   elseif (nargin == 1 && is_struct(sys))
  44.     sysupdate(sys,"ss");
  45.     [a,b,c] = sys2ss(sys);
  46.   else
  47.     usage("obsv(sys [, c])")
  48.   endif
  49.  
  50.   if (!is_abcd(a,c'))
  51.     Qb = [];
  52.   else
  53.     # no need to check dimensions, we trust is_abcd().
  54.     [na, ma] = size(a);
  55.     [nc, mc] = size(c);
  56.     Qb = zeros(na*nc, ma);
  57.     for i = 1:na
  58.       Qb((i-1)*nc+1:i*nc, :) = c;
  59.       c = c * a;
  60.     endfor
  61.   endif
  62. endfunction
  63.