0001 function plo = parseFilterParams(pl)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 plo = plist();
0022
0023
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
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
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
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
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
0073 win = find(pl, 'Win');
0074 if isempty(win)
0075
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