home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / control / tfout.m < prev    next >
Text File  |  1999-04-29  |  2KB  |  65 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 tfout(num,denom,x)
  18. #
  19. # usage: tfout(num,denom[,x])
  20. #
  21. # print formatted transfer function num(s)/d(s) 
  22. # to the screen
  23. # x defaults to the string "s"
  24. #
  25. #  SEE ALSO: polyval, polyvalm, poly, roots, conv, deconv, residue, 
  26. #    filter, polyderv, polyintg, polyout
  27.  
  28. # Written by A. Scottedward Hodel (scotte@eng.auburn.edu) June 1995)
  29.   
  30.   save_val = implicit_str_to_num_ok;
  31.   save_empty = empty_list_elements_ok;
  32.   empty_list_elements_ok = implicit_str_to_num_ok = 1;
  33.   
  34.   if (nargin < 2 ) | (nargin > 3) | (nargout != 0 ) 
  35.     usage("tfout(num,denom[,x])");
  36.   endif
  37.  
  38.   if ( (!is_vec(num)) | (!is_vec(denom)) )
  39.     error("tfout: first two argument must be vectors");
  40.   endif
  41.   
  42.   if (nargin == 2)
  43.     x = 's';
  44.   elseif( ! isstr(x) )
  45.     error("tfout: third argument must be a string");
  46.   endif
  47.  
  48.   numstring = polyout(num,x);
  49.   denomstring = polyout(denom,x);
  50.   len = max(length(numstring),length(denomstring));
  51.   if(len > 0)
  52.     y = strrep(blanks(len)," ","-");
  53.     disp(numstring)
  54.     disp(y)
  55.     disp(denomstring)
  56.   else
  57.     error('tfout: empty transfer function')
  58.   end
  59.  
  60.   implicit_str_to_num_ok = save_val;
  61.   empty_list_elements_ok = save_empty;
  62. endfunction
  63.