Home > classes > @mfir > private > parseFilterParams.m

parseFilterParams

PURPOSE ^

PARSEFILTERPARAMS parses the input plist and returns a full plist for

SYNOPSIS ^

function plo = parseFilterParams(pl)

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.
 
 M Hewitson 11-02-09

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plo = parseFilterParams(pl)
0002 
0003 % PARSEFILTERPARAMS parses the input plist and returns a full plist for
0004 % designing a standard IIR filter.  Defaults are used for those parameters
0005 % missing from the input plist.
0006 %
0007 % M Hewitson 11-02-09
0008 %
0009       
0010 %   'type'  - one of 'highpass', 'lowpass', 'bandpass', 'bandreject'.
0011 %             [default: 'lowpass']
0012 %   'gain'  - gain of filter [default: 1.0]
0013 %   'fs'    - sample frequency to design for [default: 1Hz]
0014 %   'order' - order of filter [default: 1]
0015 %   'fc'    - corner frequencies. This is a two element vector for bandpass
0016 %             and bandreject filters. [default: 0.25 or [0.1 0.3] ]
0017 %   'Win'   - a window object to use in the design. [default: Hamming]
0018 %
0019 %
0020 
0021 plo = plist();
0022 
0023 % type
0024 type = find(pl, 'type');
0025 if isempty(type)
0026   type = 'lowpass';
0027   disp('- using default type ''lowpass''');
0028 end
0029 plo = append(plo, param('type', type));
0030 
0031 % gain
0032 gain = find(pl, 'gain');
0033 if isempty(gain)
0034   gain = 1.0;
0035   disp(['- using default gain ' num2str(gain)]);
0036 end
0037 plo = append(plo, param('gain', gain));
0038 
0039 % order
0040 order = find(pl, 'order');
0041 if isempty(order)
0042   order = 64;
0043   disp(['- using default order ' num2str(order)]);
0044 end
0045 if mod(order,2) == 1
0046   warning('!!! reseting filter order to even number (+1)')
0047   order = order + 1;
0048 end
0049 plo = append(plo, param('order', order));
0050 
0051 % fc
0052 fc = find(pl, 'fc');
0053 if isempty(fc)
0054   if strcmp(type, 'bandreject') | strcmp(type, 'bandpass')
0055     fc = [0.1 0.2];
0056   else
0057     fc = 0.25;
0058   end
0059   disp(['- using default fc ' num2str(fc)]);
0060 end
0061 plo = append(plo, param('fc', fc));
0062 
0063 % fs
0064 fs = find(pl, 'fs');
0065 if isempty(fs)
0066   fs = 10*max(fc);
0067   warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2fHz.', fs)...
0068            sprintf('\nThe filter will be redesigned later when used.')]); 
0069 end
0070 plo = append(plo, param('fs', fs));
0071 
0072 % win
0073 win = find(pl, 'Win');
0074 if isempty(win)
0075   % then we use the default window
0076   win = specwin('Hamming', order+1);
0077 end
0078 if length(win.win) ~= order + 1
0079   warning('!!! setting window length to filter order !!!');
0080   switch win.name
0081     case {'Kaiser', 'Flattop'}
0082       win = specwin(win.name, order + 1, win.psll);
0083     otherwise
0084       win = specwin(win.name, order + 1);
0085   end
0086 end
0087 plo = append(plo, param('Win', win));
0088 
0089 
0090

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