Mercurial > hg > ltpda
diff m-toolbox/classes/@ao/fromSpecWin.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@ao/fromSpecWin.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,74 @@ +% FROMSPECWIN Construct an ao from a Spectral window +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% FUNCTION: fromSpecWin +% +% DESCRIPTION: Construct an ao from a Spectral window +% +% CALL: a = fromSpecWin(a, win) +% +% PARAMETER: win: Spectral window object +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +function a = fromSpecWin(a, pli) + + VERSION = '$Id: fromSpecWin.m,v 1.21 2011/08/15 06:50:45 hewitson Exp $'; + + % get AO info + ii = ao.getInfo('ao', 'From Window'); + + % Set the method version string in the minfo object + ii.setMversion([VERSION '-->' ii.mversion]); + + % If the user input a specwin object, construct an appropriate plist + if isa(pli, 'specwin') + pli = toPlist(pli); + end + + % If the 'win' value in the input plist is a specwin object, expand it in + % to plist keys + if isa(pli.find('win'), 'specwin') + win = pli.find('win'); + pli.remove('win'); + pli.append(toPlist(win)); + end + + % Apply defaults + pl = applyDefaults(ii.plists, pli); + win = find(pl, 'win'); + + if ischar(win) + len = pl.find('length'); + switch lower(win) + case 'kaiser' + psll = pl.find('psll'); + win = specwin(win, len, psll); + case 'levelledhanning' + levelorder = pl.find('levelorder'); + win = specwin(win, len, levelorder); + otherwise + win = specwin(win, len); + end + pl.pset('win', win.type); + else + % we have a specwin and we just use the values + end + + % Make a cdata object + a.data = cdata(win.win); + if isempty(pl.find('name')) + pl.pset('name', sprintf('ao(%s)', win.type)); + end + + % Add history + a.addHistory(ii, pl, [], []); + + % Set Yunits + a.setYunits(pl.find('yunits')); + + % Set object properties from plist + a.setObjectProperties(pl); + +end + +