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

  1. # Copyright (C) 1996,1998 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 sys = fir2sys (num,tsam,inname,outname)
  18.   #
  19.   # outsys = fir2sys(num,{tsam,inname,outname})
  20.   # construct a system data structure from FIR description
  21.   # inputs:
  22.   #   num: vector of coefficients [c0 c1 ... cn] of the SISO FIR transfer
  23.   #        function C(z) = c0 + c1*z^{-1} + c2*z^{-2} + ... + znz^{-n}
  24.   #   tsam: sampling time (default: 1)
  25.   #   inname: name of input signal 
  26.   #   outname: name of output signal
  27.   # outputs:  sys (system data structure)
  28.    
  29.   #  Written by R. Bruce Tenison  July 29, 1994
  30.   #  Name changed to TF2SYS July 1995
  31.   #  updated for new system data structure format July 1996
  32.   # adapted from tf2sys july 1996
  33.  
  34.   save_val = implicit_str_to_num_ok;
  35.   implicit_str_to_num_ok = 1;
  36.  
  37.   #  Test for the correct number of input arguments
  38.   if (nargin < 1 | nargin > 4)
  39.     usage('sys=fir2sys(num[,tsam,inname,outname])');
  40.   endif
  41.  
  42.   # let tf2sys do the argument checking
  43.   den = [1,zeros(1,length(num)-1)];
  44.  
  45.   # check sampling interval (if any)
  46.   if(nargin <= 1)               tsam = 1;        # default 
  47.   elseif (isempty(tsam))        tsam = 1;        endif
  48.  
  49.   #  Set name of input
  50.   if(nargin < 3)  inname = sysdefioname(1,"u");        endif
  51.  
  52.   #  Set name of output
  53.   if(nargin < 4)  outname = sysdefioname(1,"y");     endif
  54.  
  55.   sys = tf2sys(num,den,tsam,inname,outname);
  56.   
  57.   implicit_str_to_num_ok = save_val;
  58. endfunction
  59.