


TOMFIR approximates a pole/zero model with an FIR filter.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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.
CALL: 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]
VERSION: $Id: tomfir.m,v 1.2 2008/01/08 14:57:07 ingo Exp $
HISTORY: 16-08-07 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0001 function varargout = tomfir(varargin) 0002 % TOMFIR approximates a pole/zero model with an FIR filter. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: TOMFIR approximates a pole/zero model with an FIR filter. 0007 % The response of the pzmodel is computed using pzmodel/resp with 0008 % the additional input parameter of param('f1', 0). The final 0009 % frequency in the response is set automatically from the 0010 % pzmodel/resp function if not specified as an input. This upper 0011 % frequency is then taken as the Nyquist frequency and the 0012 % sample rate of the corresponding fsdata AO is set accordingly. 0013 % The function then calls mfir() with the new fsdata AO as input. 0014 % The result is an FIR filter designed to have a magnitude response 0015 % equal to the magnitude response of the pole/zero model. The filter 0016 % has linear phase and the phase of the pzmodel is ignored. 0017 % 0018 % CALL: f = tomfir(pzm) 0019 % f = tomfir(pzm, plist) 0020 % 0021 % PARAMETERS: f2 - the upper frequency. Sets the Nyquist rate used in the 0022 % conversion. [default taken from pzmodel/resp] 0023 % nf - Sets the number of frequency points used in the conversion 0024 % [default: 1000] 0025 % 0026 % VERSION: $Id: tomfir.m,v 1.2 2008/01/08 14:57:07 ingo Exp $ 0027 % 0028 % HISTORY: 16-08-07 M Hewitson 0029 % Creation 0030 % 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 VERSION = '$Id: tomfir.m,v 1.2 2008/01/08 14:57:07 ingo Exp $'; 0034 0035 % Check if this is a call for parameters 0036 if nargin == 2 0037 if isa(varargin{1}, 'pzmodel') && ischar(varargin{2}) 0038 in = char(varargin{2}); 0039 if strcmp(in, 'Params') 0040 varargout{1} = plist; 0041 return 0042 elseif strcmp(in, 'Version') 0043 varargout{1} = VERSION; 0044 return 0045 end 0046 end 0047 end 0048 0049 pl = plist; 0050 0051 if nargin == 1 0052 pzm = varargin{1}; 0053 elseif nargin == 2 0054 pzm = varargin{1}; 0055 pl = varargin{2}; 0056 else 0057 error('### Incorrect inputs.'); 0058 end 0059 0060 % check design parameters 0061 fs = find(pl, 'fs'); 0062 0063 % if isempty(nf) 0064 % nf = 1000; 0065 % end 0066 % % compute response of model 0067 % if isempty(f2) 0068 % r = resp(pzm, plist('f1', 0, 'nf', nf)); 0069 % else 0070 % r = resp(pzm, plist('f1', 0, 'f2', f2, 'nf', nf)); 0071 % end 0072 0073 r = resp(pzm, plist('f1', 0, 'f2', fs/2, 'nf', 1000)); 0074 0075 % Set fs 0076 r = set(r, 'fs', fs); 0077 0078 % compute filter 0079 f = mfir(r); 0080 0081 if nargout == 1 0082 varargout{1} = f; 0083 else 0084 error('### Incorrect outputs.'); 0085 end 0086 0087 0088 % END