Mercurial > hg > ltpda
diff m-toolbox/classes/@ao/ifft.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/ifft.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,105 @@ +% IFFT overloads the ifft operator for Analysis objects. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: IFFT overloads the ifft operator for Analysis objects. +% +% CALL: b = ifft(a, pl) +% +% <a href="matlab:utils.helper.displayMethodInfo('ao', 'ifft')">Parameters Description</a> +% +% VERSION: $Id: ifft.m,v 1.31 2011/04/28 21:31:31 mauro Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = ifft(varargin) + + % Check if this is a call for parameters + if utils.helper.isinfocall(varargin{:}) + varargout{1} = getInfo(varargin{3}); + return + end + + import utils.const.* + utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); + + % Collect input variable names + in_names = cell(size(varargin)); + for ii = 1:nargin,in_names{ii} = inputname(ii);end + + % Collect all AOs and plists + [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); + + % Decide on a deep copy or a modify + bs = copy(as, nargout); + + % Apply defaults to plist + pl = applyDefaults(getDefaultPlist, varargin{:}); + + % two-sided or one? + type = find(pl, 'type'); + + % scale? + scale = utils.prog.yes2true(find(pl, 'scale')); + + % Check input analysis object + for jj = 1:numel(bs) + + % call core method of the fft + bs(jj).ifft_core(type); + if scale + bs(jj) = bs(jj)./ao(plist('vals',1/as(jj).fs,'yunits','Hz^-1')); + bs(jj).simplifyYunits(); + end + % Set name + bs(jj).name = sprintf('ifft(%s)', ao_invars{jj}); + % Add history + bs(jj).addHistory(getInfo('None'), pl, ao_invars, bs(jj).hist); + + end + + % Set output + varargout = utils.helper.setoutputs(nargout, bs); +end + +%-------------------------------------------------------------------------- +% Get Info Object +%-------------------------------------------------------------------------- +function ii = getInfo(varargin) + if nargin == 1 && strcmpi(varargin{1}, 'None') + sets = {}; + pl = []; + else + sets = {'Default'}; + pl = getDefaultPlist(); + end + % Build info object + ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: ifft.m,v 1.31 2011/04/28 21:31:31 mauro Exp $', sets, pl); +end + +%-------------------------------------------------------------------------- +% Get Default Plist +%-------------------------------------------------------------------------- +function plout = getDefaultPlist() + persistent pl; + if ~exist('pl', 'var') || isempty(pl) + pl = buildplist(); + end + plout = pl; +end + +function pl = buildplist() + + pl = plist(); + + % Type + p = param({'type', 'Assume the data is symmetric or nonsymmetric.'}, {1, {'symmetric', 'nonsymmetric'}, paramValue.SINGLE}); + pl.append(p); + + % Scale by sample rate? + p = param({'scale',['set to ''true'' to scale FFT by sampling rate to match '... + 'amplitude in continuous domain. Only applicable to data with sampel rates.']},... + paramValue.FALSE_TRUE); + pl.append(p); + +end +