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
 
 
 $Id: parseFilterParams.html,v 1.14 2008/03/31 10:27:37 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 IIR 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:37 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: 1]
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 
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 = 1.0;
0043   disp(['- using default order ' num2str(order)]);
0044 end
0045 plo = append(plo, param('order', order));
0046 
0047 % fc
0048 fc = find(pl, 'fc');
0049 if isempty(fc)
0050   if strcmp(type, 'bandreject') | strcmp(type, 'bandpass')
0051     fc = [0.1 0.25];
0052   else
0053     fc = 0.1;
0054   end
0055   disp(['- using default fc ' num2str(fc)]);
0056 end
0057 plo = append(plo, param('fc', fc));
0058 
0059 % fs
0060 fs = find(pl, 'fs');
0061 if isempty(fs)
0062   fs = 10*max(fc);
0063   warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2fHz.', fs)...
0064            sprintf('\nThe filter will be redesigned later when used.')]); 
0065 end
0066 plo = append(plo, param('fs', fs));
0067 
0068 % ripple
0069 ripple = find(pl, 'ripple');
0070 if isempty(ripple)
0071   ripple = 0.5;
0072   disp(['- using default ripple ' num2str(ripple)]);
0073 end
0074 plo = append(plo, param('ripple', ripple));
0075 
0076 
0077 
0078

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