Home > classes > @ao > fft.m

fft

PURPOSE ^

FFT overloads the fft operator for Analysis objects.

SYNOPSIS ^

function varargout = fft(varargin)

DESCRIPTION ^

 FFT overloads the fft operator for Analysis objects.

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

 DESCRIPTION: FFT overloads the fft operator for Analysis objects.

 CALL:        b = fft(a)

 VERSION:     $Id: fft.html,v 1.14 2008/03/31 10:27:33 hewitson Exp $

 The following call returns a parameter list object that contains the
 default parameter values:

 >> pl = fft(ao, 'Params')

 The following call returns a string that contains the routine CVS version:

 >> version = fft(ao,'Version')

 The following call returns a string that contains the routine category:

 >> category = fft(ao,'Category')

 HISTORY: 12-03-07 M Hewitson
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = fft(varargin)
0002 % FFT overloads the fft operator for Analysis objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: FFT overloads the fft operator for Analysis objects.
0007 %
0008 % CALL:        b = fft(a)
0009 %
0010 % VERSION:     $Id: fft.html,v 1.14 2008/03/31 10:27:33 hewitson Exp $
0011 %
0012 % The following call returns a parameter list object that contains the
0013 % default parameter values:
0014 %
0015 % >> pl = fft(ao, 'Params')
0016 %
0017 % The following call returns a string that contains the routine CVS version:
0018 %
0019 % >> version = fft(ao,'Version')
0020 %
0021 % The following call returns a string that contains the routine category:
0022 %
0023 % >> category = fft(ao,'Category')
0024 %
0025 % HISTORY: 12-03-07 M Hewitson
0026 %             Creation
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 ALGONAME = mfilename;
0031 VERSION  = '$Id: fft.html,v 1.14 2008/03/31 10:27:33 hewitson Exp $';
0032 CATEGORY = 'Signal Processing';
0033 bs       = [];
0034 
0035 % Check if this is a call for parameters
0036 if nargin == 2
0037   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0038     in = char(varargin{2});
0039     if strcmp(in, 'Params')
0040       varargout{1} = getDefaultPL();
0041       return
0042     elseif strcmp(in, 'Version')
0043       varargout{1} = VERSION;
0044       return
0045     elseif strcmp(in, 'Category')
0046       varargout{1} = CATEGORY;
0047       return
0048     end
0049   end
0050 end
0051 
0052 % Collect input ao's, plist's and ao variable names
0053 in_names = {};
0054 for ii = 1:nargin
0055   in_names{end+1} = inputname(ii);
0056 end
0057 
0058 [as, ps, invars] = collect_inputs(varargin, in_names);
0059 
0060 
0061 % Check input analysis object
0062 for j=1:numel(as)
0063   a     = as(j);
0064   d     = get(a, 'data');
0065   dinfo = whos('d');
0066 
0067   % Which data type do we have
0068   dtype = dinfo.class;
0069   switch dtype
0070     case 'tsdata'
0071 
0072       % make a new fsdata object
0073       nfft = length(d.y);
0074       ft   = fft(d.y);
0075       ft   = ft(1:nfft/2+1);
0076       f    = linspace(0, d.fs/2, length(ft));
0077       fsd = fsdata(f, ft, d.fs);
0078       fsd = set(fsd, 'name', sprintf('fft(%s)', d.name));
0079       fsd = set(fsd, 'xunits', 'Hz');
0080       fsd = set(fsd, 'yunits', '');
0081 
0082       % make a new history object
0083       h = history(ALGONAME, VERSION, plist(), [a.hist]);
0084       h = set(h, 'invars', cellstr(invars{j}));
0085 
0086       % make output analysis object
0087       b = ao(fsd, h);
0088       b = setnh(b, 'name', sprintf('fft(%s)', invars{j}));
0089 
0090     case {'fsdata', 'cdata', 'xydata'}
0091       error('### I don''t work for frequency-series, xy and constant data yet.');
0092       disp('* FFT of fsdata object');
0093 
0094 
0095     otherwise
0096       error('### unknown data type. They can not be addded.')
0097   end
0098 
0099   % add to output
0100   bs = [bs b];
0101 end
0102 
0103 % Reshape the ouput to the same size of the input
0104 bs = reshape(bs, size(as));
0105 
0106 varargout{1} = bs;
0107 
0108 
0109 %--------------------------------------------------------------------------
0110 % Get default params
0111 function plo = getDefaultPL()
0112 
0113 plo = plist();
0114 
0115 % END

Generated on Mon 31-Mar-2008 12:20:24 by m2html © 2003