PARSEFILTERPARAMS parses the input plist and returns a full plist for designing a standard IIR filter. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: PARSEFILTERPARAMS parses the input plist and returns a full plist for designing a standard IIR filter. Defaults are used for those parameters missing from the input plist. CALL: plo = parseFilterParams(pl) INPUT: 'type' - one of 'highpass', 'lowpass', 'bandpass', 'bandreject' [default: 'lowpass'] 'gain' - gain of filter [default: 1.0] 'fs' - sample frequency to design for [default: 1 Hz] 'order' - order of filter [default: 1] 'fc' - corner frequencies. This is a two element vector for bandpass and bandreject filters. [default: 0.1 or [0.1 0.25] Hz] VERSION: $Id: parseFilterParams.m,v 1.4 2008/08/08 14:52:24 hewitson Exp $ HISTORY: 11-02-2008 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % PARSEFILTERPARAMS parses the input plist and returns a full plist for designing a standard IIR filter. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: PARSEFILTERPARAMS parses the input plist and returns a 0005 % full plist for designing a standard IIR filter. Defaults are used 0006 % for those parameters missing from the input plist. 0007 % 0008 % CALL: plo = parseFilterParams(pl) 0009 % 0010 % INPUT: 'type' - one of 'highpass', 'lowpass', 'bandpass', 'bandreject' 0011 % [default: 'lowpass'] 0012 % 'gain' - gain of filter 0013 % [default: 1.0] 0014 % 'fs' - sample frequency to design for 0015 % [default: 1 Hz] 0016 % 'order' - order of filter 0017 % [default: 1] 0018 % 'fc' - corner frequencies. This is a two element vector for 0019 % bandpass and bandreject filters. 0020 % [default: 0.1 or [0.1 0.25] Hz] 0021 % 0022 % VERSION: $Id: parseFilterParams.m,v 1.4 2008/08/08 14:52:24 hewitson Exp $ 0023 % 0024 % HISTORY: 11-02-2008 M Hewitson 0025 % Creation 0026 % 0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0028 0029 function plo = parseFilterParams(pl) 0030 0031 plo = plist(); 0032 0033 % type 0034 type = find(pl, 'type'); 0035 if isempty(type) 0036 type = 'lowpass'; 0037 utils.helper.msg(msg.OPROC2, 'using default type ''lowpass'''); 0038 end 0039 plo = append(plo, param('type', type)); 0040 0041 % gain 0042 gain = find(pl, 'gain'); 0043 if isempty(gain) 0044 gain = 1.0; 0045 utils.helper.msg(msg.OPROC2, ['using default gain ' num2str(gain)]); 0046 end 0047 plo = append(plo, param('gain', gain)); 0048 0049 % order 0050 order = find(pl, 'order'); 0051 if isempty(order) 0052 order = 1.0; 0053 utils.helper.msg(msg.OPROC2, ['using default order ' num2str(order)]); 0054 end 0055 plo = append(plo, param('order', order)); 0056 0057 % fc 0058 fc = find(pl, 'fc'); 0059 if isempty(fc) 0060 if strcmp(type, 'bandreject') || strcmp(type, 'bandpass') 0061 fc = [0.1 0.25]; 0062 else 0063 fc = 0.1; 0064 end 0065 utils.helper.msg(msg.OPROC2, ['using default fc ' num2str(fc)]); 0066 end 0067 plo = append(plo, param('fc', fc)); 0068 0069 % fs 0070 fs = find(pl, 'fs'); 0071 if isempty(fs) 0072 fs = 10*max(fc); 0073 warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2fHz.', fs)... 0074 sprintf('\nThe filter will be redesigned later when used.')]); 0075 end 0076 % Increase fs until the cutoff is ok 0077 while fs < 2*fc 0078 fs = fs*2; 0079 end 0080 plo = append(plo, param('fs', fs)); 0081 0082 % ripple 0083 ripple = find(pl, 'ripple'); 0084 if isempty(ripple) 0085 ripple = 0.5; 0086 utils.helper.msg(msg.OPROC2, ['using default ripple ' num2str(ripple)]); 0087 end 0088 plo = append(plo, param('ripple', ripple)); 0089 end 0090 0091 0092