0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 1 % FFT overloads the fft method for Analysis objects.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 3 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 4 % DESCRIPTION: FFT overloads the fft operator for Analysis objects.
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 5 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 6 % CALL: b = fft(a, pl)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 7 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 8 % PARAMETERS: 'type' - plain, one or two sided fft [default: 'plain']
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 9 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 10 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'fft')">Parameters Description</a>
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 11 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 12 % VERSION: $Id: fft.m,v 1.50 2011/04/28 21:31:31 mauro Exp $
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 13 %
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 15
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 16 function varargout = fft(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 17
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 18 % Check if this is a call for parameters
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 19 if utils.helper.isinfocall(varargin{:})
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 20 varargout{1} = getInfo(varargin{3});
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 21 return
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 22 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 23
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 24 import utils.const.*
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 25 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 26
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 27 % Collect input variable names
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 28 in_names = cell(size(varargin));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 29 for ii = 1:nargin,in_names{ii} = inputname(ii);end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 30
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 31 % Collect all AOs
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 32 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 33
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 34 % Decide on a deep copy or a modify
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 35 bs = copy(as, nargout);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 36
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 37 % Apply defaults to plist
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 38 pl = applyDefaults(getDefaultPlist, varargin{:});
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 39
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 40 % two-sided or one?
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 41 type = find(pl, 'type');
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 42
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 43 % scale?
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 44 scale = utils.prog.yes2true(find(pl, 'scale'));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 45
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 46 % Check input analysis object
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 47 for jj = 1:numel(bs)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 48 % call core method of the fft
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 49 bs(jj).fft_core(type);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 50 % scale if desired
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 51 if scale
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 52 bs(jj) = bs(jj)./ao(plist('vals',as(jj).fs,'yunits','Hz'));
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 53 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 54 % set name
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 55 bs(jj).name = sprintf('fft(%s)', ao_invars{jj});
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 56 % Add history
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 57 bs(jj).addHistory(getInfo('None'), pl, ao_invars(jj), bs(jj).hist);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 58 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 59
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 60 % Set output
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 61 varargout = utils.helper.setoutputs(nargout, bs);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 62 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 63
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 64 %--------------------------------------------------------------------------
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 65 % Get Info Object
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 66 %--------------------------------------------------------------------------
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 67 function ii = getInfo(varargin)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 68 if nargin == 1 && strcmpi(varargin{1}, 'None')
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 69 sets = {};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 70 pl = [];
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 71 else
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 72 sets = {'Default'};
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 73 pl = getDefaultPlist();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 74 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 75 % Build info object
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 76 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: fft.m,v 1.50 2011/04/28 21:31:31 mauro Exp $', sets, pl);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 77 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 78
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 79 %--------------------------------------------------------------------------
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 80 % Get Default Plist
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 81 %--------------------------------------------------------------------------
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 82 function plout = getDefaultPlist()
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 83 persistent pl;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 84 if ~exist('pl', 'var') || isempty(pl)
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 85 pl = buildplist();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 86 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 87 plout = pl;
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 88 end
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 89
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 90 function plo = buildplist()
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 91 plo = plist();
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 92
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 93 % FFT Type
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 94 p = plist({'type', 'The fft type. Plain (complete non-symmetric), One-sided (from zero to Nyquist) or two-sided (complete symmetric).'}, {2, {'plain', 'one', 'two'}, paramValue.SINGLE});
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 95 plo.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 96
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 97 % Scale by sample rate?
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 98 p = param({'scale',['set to ''true'' to scale FFT by sampling rate to match '...
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 99 'amplitude in continuous domain. Only applicable to time-series AOs.']},...
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 100 paramValue.FALSE_TRUE);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 101
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 102 plo.append(p);
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 103
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
+ − 104 end