Home > classes > @miir > 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 
0018 plo = plist();
0019 
0020 % type
0021 type = find(pl, 'type');
0022 if isempty(type)
0023   type = 'lowpass';
0024   disp('- using default type ''lowpass''');
0025 end
0026 plo = append(plo, param('type', type));
0027 
0028 % gain
0029 gain = find(pl, 'gain');
0030 if isempty(gain)
0031   gain = 1.0;
0032   disp(['- using default gain ' num2str(gain)]);
0033 end
0034 plo = append(plo, param('gain', gain));
0035 
0036 % order
0037 order = find(pl, 'order');
0038 if isempty(order)
0039   order = 1.0;
0040   disp(['- using default order ' num2str(order)]);
0041 end
0042 plo = append(plo, param('order', order));
0043 
0044 % fc
0045 fc = find(pl, 'fc');
0046 if isempty(fc)
0047   if strcmp(type, 'bandreject') | strcmp(type, 'bandpass')
0048     fc = [0.1 0.2];
0049   else
0050     fc = 0.25;
0051   end
0052   disp(['- using default fc ' num2str(fc)]);
0053 end
0054 plo = append(plo, param('fc', fc));
0055 
0056 % fs
0057 fs = find(pl, 'fs');
0058 if isempty(fs)
0059   fs = 10*max(fc);
0060   warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2fHz.', fs)...
0061            sprintf('\nThe filter will be redesigned later when used.')]); 
0062 end
0063 plo = append(plo, param('fs', fs));
0064 
0065 % ripple
0066 ripple = find(pl, 'ripple');
0067 if isempty(ripple)
0068   ripple = 0.5;
0069   disp(['- using default ripple ' num2str(ripple)]);
0070 end
0071 plo = append(plo, param('ripple', ripple));
0072 
0073 
0074 
0075

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