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