


DFT computes the DFT of the input time-series at the requested frequencies.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: DFT computes the DFT of the input time-series at the requested
frequencies.
CALL: b = dft(a, pl)
PARAMETERS:
'f' - vector of frequencies at which to compute the DFT.
[default: linspace(1/ndata,fs/2,ndata/2+1)]
M-FILE INFO: Get information about this methods by calling
>> ao.getInfo('dft')
Get information about a specified set-plist by calling:
>> ao.getInfo('dft', 'None')
VERSION: $Id: dft.m,v 1.10 2008/08/15 11:45:18 ingo Exp $
HISTORY: 25-04-08 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 % DFT computes the DFT of the input time-series at the requested frequencies. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: DFT computes the DFT of the input time-series at the requested 0005 % frequencies. 0006 % 0007 % CALL: b = dft(a, pl) 0008 % 0009 % PARAMETERS: 0010 % 'f' - vector of frequencies at which to compute the DFT. 0011 % [default: linspace(1/ndata,fs/2,ndata/2+1)] 0012 % 0013 % M-FILE INFO: Get information about this methods by calling 0014 % >> ao.getInfo('dft') 0015 % 0016 % Get information about a specified set-plist by calling: 0017 % >> ao.getInfo('dft', 'None') 0018 % 0019 % VERSION: $Id: dft.m,v 1.10 2008/08/15 11:45:18 ingo Exp $ 0020 % 0021 % HISTORY: 25-04-08 M Hewitson 0022 % Creation 0023 % 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 0026 function varargout = dft(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 0042 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0043 [pl, pl_invars] = utils.helper.collect_objects(varargin(:), 'plist', in_names); 0044 0045 % Make copies or handles to inputs 0046 bs = copy(as, nargout); 0047 0048 % Combine plists 0049 pl = combine(pl, getDefaultPlist); 0050 0051 % Extract necessary parameters 0052 f = find(pl, 'f'); 0053 0054 % Loop over input AOs 0055 for j=1:length(bs) 0056 if ~isa(bs(j).data, 'tsdata') 0057 warning('!!! The DFT can only be computed on input time-series. Skipping AO %s', ao_invars{j}); 0058 else 0059 % Compute f if necessary 0060 if f < 0 0061 f = linspace(0, bs(j).data.fs/2, length(bs(j).data.y)/2+1); 0062 end 0063 0064 % Compute DFT 0065 fs = bs(j).data.fs; 0066 N = length(bs(j).data.y); 0067 J = -2*pi*1i.*[0:N-1]/fs; 0068 dft = zeros(size(f)); 0069 for kk = 1:length(f) 0070 dft(kk) = exp(f(kk)*J)*bs(j).data.y.'; 0071 end 0072 0073 % Make output fsdata AO 0074 yunits = bs(j).data.yunits; 0075 bs(j).data = fsdata(f, dft, bs(j).data.fs); 0076 bs(j).setXunits('Hz', 'internal'); 0077 bs(j).setYunits(yunits/sym('Hz'), 'internal'); 0078 % Set name 0079 bs(j).setName(sprintf('dft(%s)', ao_invars{j}), 'internal'); 0080 % Add history 0081 bs(j).addHistory(getInfo, pl, ao_invars(j), bs(j).hist); 0082 end 0083 end 0084 0085 % Set outputs 0086 if nargout > 0 0087 varargout{1} = bs; 0088 end 0089 end 0090 0091 %-------------------------------------------------------------------------- 0092 % Get Info Object 0093 %-------------------------------------------------------------------------- 0094 function ii = getInfo(varargin) 0095 if nargin == 1 && strcmpi(varargin{1}, 'None') 0096 sets = {}; 0097 pls = []; 0098 else 0099 sets = {'Default'}; 0100 pls = getDefaultPlist; 0101 end 0102 % Build info object 0103 ii = minfo(mfilename, 'ao', '', 'Signal Processing', '$Id: dft.m,v 1.10 2008/08/15 11:45:18 ingo Exp $', sets, pls); 0104 end 0105 0106 %-------------------------------------------------------------------------- 0107 % Get Default Plist 0108 %-------------------------------------------------------------------------- 0109 function pl = getDefaultPlist() 0110 pl = plist('f', -1); 0111 end 0112 0113