IFFT overloads the ifft operator for Analysis objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: IFFT overloads the ifft operator for Analysis objects. CALL: b = ifft(a, pl) PARAMETERS: 'type' - symmetric or nonsymmetric [default: 'symmetric'] 'twoside' - generate a two-sided spectrum from the single sided input. Specify 'yes' or 'no' [default: yes]. M-FILE INFO: Get information about this methods by calling >> ao.getInfo('ifft') Get information about a specified set-plist by calling: >> ao.getInfo('ifft', 'None') VERSION: $Id: ifft.m,v 1.11 2008/09/08 08:30:56 hewitson Exp $ HISTORY: 26-05-08 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % IFFT overloads the ifft operator for Analysis objects. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: IFFT overloads the ifft operator for Analysis objects. 0005 % 0006 % CALL: b = ifft(a, pl) 0007 % 0008 % PARAMETERS: 0009 % 'type' - symmetric or nonsymmetric [default: 'symmetric'] 0010 % 'twoside' - generate a two-sided spectrum from the single 0011 % sided input. Specify 'yes' or 'no' [default: yes]. 0012 % 0013 % M-FILE INFO: Get information about this methods by calling 0014 % >> ao.getInfo('ifft') 0015 % 0016 % Get information about a specified set-plist by calling: 0017 % >> ao.getInfo('ifft', 'None') 0018 % 0019 % VERSION: $Id: ifft.m,v 1.11 2008/09/08 08:30:56 hewitson Exp $ 0020 % 0021 % HISTORY: 26-05-08 M Hewitson 0022 % Creation 0023 % 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 0026 function varargout = ifft(varargin) 0027 0028 % Check if this is a call for parameters 0029 if utils.helper.isinfocall(varargin{:}) 0030 varargout{1} = getInfo(varargin{3}); 0031 return 0032 end 0033 0034 import utils.const.* 0035 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 0036 0037 % Collect input variable names 0038 in_names = cell(size(varargin)); 0039 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0040 0041 % Collect all AOs and plists 0042 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0043 pl = utils.helper.collect_objects(varargin(:), 'plist', in_names); 0044 0045 % Decide on a deep copy or a modify 0046 bs = copy(as, nargout); 0047 0048 % combine plists 0049 pl = combine(pl, getDefaultPlist()); 0050 0051 % two-sided or one? 0052 type = find(pl, 'type'); 0053 twoside = find(pl, 'twoside'); 0054 0055 % Check input analysis object 0056 for j=1:numel(bs) 0057 switch class(bs(j).data) 0058 case {'fsdata'} 0059 if strcmpi(twoside, 'YES') 0060 y = [bs(j).data.getY; bs(j).data.getY(end-1:-1:2)]; 0061 else 0062 y = bs(j).data.y; 0063 end 0064 % make a new fsdata object 0065 y = ifft(y, type); 0066 % compute time axis 0067 N = length(y); 0068 x = linspace(0, (N-1)/bs(j).data.fs, N); 0069 % Keep the data shape if the input AO 0070 if size(bs(j).data.y,1) == 1 0071 x = x.'; 0072 y = y.'; 0073 end 0074 fsd = tsdata(x, y); 0075 fsd.setXunits('s'); 0076 fsd.setYunits('arb'); 0077 0078 % Set data 0079 bs(j).data = fsd; 0080 % Set name 0081 bs(j).setName(sprintf('ifft(%s)', ao_invars{j}), 'internal'); 0082 % Add history 0083 bs(j).addHistory(getInfo, pl, ao_invars(j), bs(j).hist); 0084 0085 case {'tsdata', 'cdata', 'xydata'} 0086 error('### I don''t work for time-series, constant or x/y data.'); 0087 otherwise 0088 error('### unknown data type.') 0089 end 0090 end 0091 0092 % Set output 0093 if nargout > 0 0094 varargout{1} = bs; 0095 end 0096 end 0097 0098 %-------------------------------------------------------------------------- 0099 % Get Info Object 0100 %-------------------------------------------------------------------------- 0101 function ii = getInfo(varargin) 0102 if nargin == 1 && strcmpi(varargin{1}, 'None') 0103 sets = {}; 0104 pl = []; 0105 else 0106 sets = {'Default'}; 0107 pl = getDefaultPlist; 0108 end 0109 % Build info object 0110 ii = minfo(mfilename, 'ao', '', utils.const.categories.sigproc, '$Id: ifft.m,v 1.11 2008/09/08 08:30:56 hewitson Exp $', sets, pl); 0111 end 0112 0113 %-------------------------------------------------------------------------- 0114 % Get Default Plist 0115 %-------------------------------------------------------------------------- 0116 function pl_default = getDefaultPlist() 0117 pl_default = plist('type', 'symmetric', 'twoside', 'yes'); 0118 end 0119 0120