home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / control / ss2zp.m < prev    next >
Text File  |  1999-03-05  |  2KB  |  53 lines

  1. # Copyright (C) 1996 A. Scottedward Hodel 
  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 [zer,pol,k] = ss2zp(a,b,c,d)
  18. # Converts a state space representation to a set of poles and zeros.
  19. #
  20. # [pol,zer,k] = ss2zp(a,b,c,d) returns the poles and zeros of the state space 
  21. # system (a,b,c,d).  K is a gain associated with the zeros.
  22. #
  23. # used internally in system data structure manipulations
  24.  
  25. # Written by David Clem August 15, 1994
  26. # Hodel: changed order of output arguments to zer, pol, k. July 1996
  27. # a s hodel: added argument checking, allow for pure gain blocks aug 1996
  28.  
  29.   if(nargin != 4)
  30.     usage("[zer,pol,k] = ss2zp(a,b,c,d)");
  31.   endif
  32.  
  33.   [n,m,p] = abcddim(a,b,c,d);
  34.   if (n == -1)
  35.     error("ss2tf: Non compatible matrix arguments");
  36.   elseif ( (m != 1) | (p != 1))
  37.     error(["ss2tf: not SISO system: m=",num2str(m)," p=",num2str(p)]);
  38.   endif
  39.  
  40.   if(n == 0)
  41.     # gain block only
  42.     k = d;
  43.     zer = pol = [];
  44.   else
  45.     # First, get the denominator coefficients
  46.     [zer,k] = tzero(a,b,c,d);
  47.     pol = eig(a);
  48.   endif
  49. endfunction
  50.  
  51.