Home > classes > @pzmodel > tomfir.m

tomfir

PURPOSE ^

TOMFIR approximates a pole/zero model with an FIR filter.

SYNOPSIS ^

function varargout = tomfir(varargin)

DESCRIPTION ^

 TOMFIR approximates a pole/zero model with an FIR filter.
 
 The response of the pzmodel is computed using pzmodel/resp with the
 additional input parameter of param('f1', 0). The final frequency in the
 response is set automatically from the pzmodel/resp function if not
 specified as an input. This upper frequency is then taken as the Nyquist
 frequency and the sample rate of the corresponding fsdata AO is set
 accordingly. The function then calls mfir() with the new fsdata AO as
 input. The result is an FIR filter designed to have a magnitude response
 equal to the magnitude response of the pole/zero model. The filter has
 linear phase and the phase of the pzmodel is ignored.
 
 Usage: f = tomfir(pzm)
        f = tomfir(pzm, plist)
 
 Parameters:
        f2   - the upper frequency. Sets the Nyquist rate used in the
               conversion. [default taken from pzmodel/resp]
        nf   - Sets the number of frequency points used in the conversion
               [default: 1000]
 
 
 M Hewitson 16-08-07
 
 $Id:$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = tomfir(varargin)
0002 % TOMFIR approximates a pole/zero model with an FIR filter.
0003 %
0004 % The response of the pzmodel is computed using pzmodel/resp with the
0005 % additional input parameter of param('f1', 0). The final frequency in the
0006 % response is set automatically from the pzmodel/resp function if not
0007 % specified as an input. This upper frequency is then taken as the Nyquist
0008 % frequency and the sample rate of the corresponding fsdata AO is set
0009 % accordingly. The function then calls mfir() with the new fsdata AO as
0010 % input. The result is an FIR filter designed to have a magnitude response
0011 % equal to the magnitude response of the pole/zero model. The filter has
0012 % linear phase and the phase of the pzmodel is ignored.
0013 %
0014 % Usage: f = tomfir(pzm)
0015 %        f = tomfir(pzm, plist)
0016 %
0017 % Parameters:
0018 %        f2   - the upper frequency. Sets the Nyquist rate used in the
0019 %               conversion. [default taken from pzmodel/resp]
0020 %        nf   - Sets the number of frequency points used in the conversion
0021 %               [default: 1000]
0022 %
0023 %
0024 % M Hewitson 16-08-07
0025 %
0026 % $Id:$
0027 %
0028 
0029 pl = plist;
0030 
0031 if nargin == 1
0032   pzm = varargin{1};
0033 elseif nargin == 2
0034   pzm = varargin{1};
0035   pl  = varargin{2};
0036 else
0037   error('### Incorrect inputs.');
0038 end
0039 
0040 % check design parameters
0041 fs = find(pl, 'fs');
0042 
0043 % if isempty(nf)
0044 %   nf = 1000;
0045 % end
0046 % % compute response of model
0047 % if isempty(f2)
0048 %   r = resp(pzm, plist('f1', 0, 'nf', nf));
0049 % else
0050 %   r = resp(pzm, plist('f1', 0, 'f2', f2, 'nf', nf));
0051 % end
0052 
0053 
0054 r = resp(pzm, plist('f1', 0, 'f2', fs/2, 'nf', 1000));
0055 
0056 % Set fs
0057 r = set(r, 'fs', fs);
0058 
0059 % compute filter
0060 f = mfir(r);
0061 
0062 if nargout == 1
0063   varargout{1} = f;
0064 else
0065   error('### Incorrect outputs.');
0066 end
0067 
0068 
0069 % END

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003