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] M-FILE INFO: Get information about this methods by calling >> pzmodel.getInfo('tomfir') Get information about a specified set-plist by calling: >> pzmodel.getInfo('tomfir', 'None') VERSION: $Id: tomfir.m,v 1.7 2008/09/04 15:29:31 ingo Exp $ HISTORY: 16-08-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % TOMFIR approximates a pole/zero model with an FIR filter. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: TOMFIR approximates a pole/zero model with an FIR filter. 0005 % The response of the pzmodel is computed using pzmodel/resp with 0006 % the additional input parameter of param('f1', 0). The final 0007 % frequency in the response is set automatically from the 0008 % pzmodel/resp function if not specified as an input. This upper 0009 % frequency is then taken as the Nyquist frequency and the 0010 % sample rate of the corresponding fsdata AO is set accordingly. 0011 % The function then calls mfir() with the new fsdata AO as input. 0012 % The result is an FIR filter designed to have a magnitude response 0013 % equal to the magnitude response of the pole/zero model. The filter 0014 % has linear phase and the phase of the pzmodel is ignored. 0015 % 0016 % CALL: f = tomfir(pzm) 0017 % f = tomfir(pzm, plist) 0018 % 0019 % PARAMETERS: f2 - the upper frequency. Sets the Nyquist rate used in the 0020 % conversion. [default taken from pzmodel/resp] 0021 % nf - Sets the number of frequency points used in the conversion 0022 % [default: 1000] 0023 % 0024 % M-FILE INFO: Get information about this methods by calling 0025 % >> pzmodel.getInfo('tomfir') 0026 % 0027 % Get information about a specified set-plist by calling: 0028 % >> pzmodel.getInfo('tomfir', 'None') 0029 % 0030 % VERSION: $Id: tomfir.m,v 1.7 2008/09/04 15:29:31 ingo Exp $ 0031 % 0032 % HISTORY: 16-08-07 M Hewitson 0033 % Creation 0034 % 0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0036 0037 function varargout = tomfir(varargin) 0038 0039 %%% Check if this is a call for parameters 0040 if utils.helper.isinfocall(varargin{:}) 0041 varargout{1} = getInfo(varargin{3}); 0042 return 0043 end 0044 0045 pl = plist; 0046 0047 if nargin == 1 0048 pzm = varargin{1}; 0049 elseif nargin == 2 0050 pzm = varargin{1}; 0051 pl = varargin{2}; 0052 else 0053 error('### Incorrect inputs.'); 0054 end 0055 0056 % check design parameters 0057 fs = find(pl, 'fs'); 0058 0059 r = resp(pzm, plist('f1', 0, 'f2', fs/2, 'nf', 1000)); 0060 0061 % Set fs 0062 r.setFs(fs); 0063 0064 % compute filter 0065 f = mfir(r); 0066 0067 if nargout == 1 0068 varargout{1} = f; 0069 else 0070 error('### Incorrect outputs.'); 0071 end 0072 0073 end 0074 0075 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0076 % Local Functions % 0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0078 0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0080 % 0081 % FUNCTION: getInfo 0082 % 0083 % DESCRIPTION: Get Info Object 0084 % 0085 % HISTORY: 11-07-07 M Hewitson 0086 % Creation. 0087 % 0088 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0089 0090 function ii = getInfo(varargin) 0091 if nargin == 1 && strcmpi(varargin{1}, 'None') 0092 sets = {}; 0093 pl = []; 0094 else 0095 sets = {'Default'}; 0096 pl = getDefaultPlist; 0097 end 0098 % Build info object 0099 ii = minfo(mfilename, 'pzmodel', '', utils.const.categories.op, '$Id: tomfir.m,v 1.7 2008/09/04 15:29:31 ingo Exp $', sets, pl); 0100 end 0101 0102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0103 % 0104 % FUNCTION: getDefaultPlist 0105 % 0106 % DESCRIPTION: Get Default Plist 0107 % 0108 % HISTORY: 11-07-07 M Hewitson 0109 % Creation. 0110 % 0111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0112 0113 function plo = getDefaultPlist() 0114 plo = plist(); 0115 end 0116