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 FIR filter.  Defaults are used for those parameters
 missing from the input plist.
 
 M Hewitson 11-02-09
 
 
 $Id: parseFilterParams.html,v 1.14 2008/03/31 10:27:40 hewitson Exp $

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

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003