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.html,v 1.12 2008/03/31 10:27:37 hewitson 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.html,v 1.12 2008/03/31 10:27:37 hewitson Exp $ 0027 % 0028 % HISTORY: 16-08-07 M Hewitson 0029 % Creation 0030 % 0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0032 0033 VERSION = '$Id: tomfir.html,v 1.12 2008/03/31 10:27:37 hewitson Exp $'; 0034 CATEGORY = 'Operator'; 0035 0036 % Check if this is a call for parameters 0037 if nargin == 2 0038 if isa(varargin{1}, 'pzmodel') && ischar(varargin{2}) 0039 in = char(varargin{2}); 0040 if strcmp(in, 'Params') 0041 varargout{1} = plist; 0042 return 0043 elseif strcmp(in, 'Version') 0044 varargout{1} = VERSION; 0045 return 0046 elseif strcmp(in, 'Category') 0047 varargout{1} = CATEGORY; 0048 return 0049 end 0050 end 0051 end 0052 0053 pl = plist; 0054 0055 if nargin == 1 0056 pzm = varargin{1}; 0057 elseif nargin == 2 0058 pzm = varargin{1}; 0059 pl = varargin{2}; 0060 else 0061 error('### Incorrect inputs.'); 0062 end 0063 0064 % check design parameters 0065 fs = find(pl, 'fs'); 0066 0067 % if isempty(nf) 0068 % nf = 1000; 0069 % end 0070 % % compute response of model 0071 % if isempty(f2) 0072 % r = resp(pzm, plist('f1', 0, 'nf', nf)); 0073 % else 0074 % r = resp(pzm, plist('f1', 0, 'f2', f2, 'nf', nf)); 0075 % end 0076 0077 r = resp(pzm, plist('f1', 0, 'f2', fs/2, 'nf', 1000)); 0078 0079 % Set fs 0080 r = set(r, 'fs', fs); 0081 0082 % compute filter 0083 f = mfir(r); 0084 0085 if nargout == 1 0086 varargout{1} = f; 0087 else 0088 error('### Incorrect outputs.'); 0089 end 0090 0091 0092 % END