0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 function filt = fromAO(filt, pli)
0021
0022 import utils.const.*
0023
0024 VERSION = '$Id: fromAO.m,v 1.10 2008/09/04 13:37:14 ingo Exp $';
0025 ii = mfir.getInfo('mfir', 'From AO');
0026
0027 ii.setMversion([VERSION '-->' ii.mversion]);
0028
0029
0030 pl = combine(pli, ii.plists);
0031
0032
0033 a = find(pl, 'AO');
0034 N = find(pl, 'N');
0035 win = find(pl, 'Win');
0036 method = find(pl, 'method');
0037
0038
0039 if ~isa(a.data, 'fsdata')
0040 error('### Please use an analysis object with a fsdata data object to create a mfir object.');
0041 end
0042
0043 fs = a.data.fs;
0044 f = a.data.getX;
0045 xx = abs(a.data.getY);
0046
0047 ffm = f/(fs/2);
0048 switch method
0049 case 'frequency-sampling'
0050
0051 if length(win.win) ~= N+1
0052 warning('!!! resizing window function to match desired filter order.');
0053 if strcmp(win.type, 'Kaiser') || strcmp(win.type, 'Flattop')
0054 win = specwin(win.type, N+1, win.psll);
0055 else
0056 win = specwin(win.type, N+1);
0057 end
0058 end
0059 utils.helper.msg(msg.OPROC2, 'designing filter using frequency-sampling method [help fir2]');
0060 mtaps = fir2(N, ffm, xx, win.win);
0061 case 'least-squares'
0062 error('### this design method is not working properly yet.');
0063 if mod(length(ffm),2)
0064 ffm = ffm(1:end-1);
0065 xx = xx(1:end-1);
0066 end
0067 utils.helper.msg(msg.OPROC2, 'designing filter using least-squares method [help firls]');
0068 mtaps = firls(N, ffm, xx);
0069 case 'Parks-McClellan'
0070 error('### this design method is not working properly yet.');
0071 utils.helper.msg(msg.OPROC2, 'designing filter using Parks-McClellan method [help firpm]');
0072 mtaps = firpm(N, ffm, xx);
0073 otherwise
0074 error('### unknown filter design method.');
0075 end
0076
0077
0078 filt.setName(sprintf('fir(%s)', a.name), 'internal');
0079 filt.setFs(fs);
0080 filt.setA(mtaps);
0081 filt.setGd((filt.ntaps+1)/2);
0082 filt.setHistout(zeros(1,filt.ntaps-1));
0083
0084
0085 filt.addHistory(ii, pl, [], []);
0086
0087 end