Home > classes > @mfir > fromAO.m

fromAO

PURPOSE ^

create FIR filter from magnitude of input AO/fsdata

SYNOPSIS ^

function filt = fromAO(filt, pli)

DESCRIPTION ^

 create FIR filter from magnitude of input AO/fsdata
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    mfirFromAO

 DESCRIPTION: create FIR filter from magnitude of input AO/fsdata

 CALL:        f = mfirFromAO(a, pli, version, algoname)

 PARAMETER:   a:        Analysis object
              pli:      Parameter list object
              version:  cvs version string
              algoname: The m-file name (use the mfilename command)

 HISTORY:     22-03-2008 M Hueller
              Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % create FIR filter from magnitude of input AO/fsdata
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % FUNCTION:    mfirFromAO
0005 %
0006 % DESCRIPTION: create FIR filter from magnitude of input AO/fsdata
0007 %
0008 % CALL:        f = mfirFromAO(a, pli, version, algoname)
0009 %
0010 % PARAMETER:   a:        Analysis object
0011 %              pli:      Parameter list object
0012 %              version:  cvs version string
0013 %              algoname: The m-file name (use the mfilename command)
0014 %
0015 % HISTORY:     22-03-2008 M Hueller
0016 %              Creation
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   % Set the method version string in the minfo object
0027   ii.setMversion([VERSION '-->' ii.mversion]);
0028 
0029   % Add default values
0030   pl = combine(pli, ii.plists);
0031 
0032   % Get parameters
0033   a      = find(pl, 'AO');
0034   N      = find(pl, 'N');
0035   win    = find(pl, 'Win');
0036   method = find(pl, 'method');
0037 
0038   % Check that a.data is a fsdata object
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       % check window
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   % Make mfir object
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   % Add history
0085   filt.addHistory(ii, pl, [], []);
0086 
0087 end % function f = mfirFromAO(a, pli, version, algoname)

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003