Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/cpsd.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children | bc767aaa99a8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % CPSD estimates the cross-spectral density between time-series objects | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: CPSD estimates the cross-spectral density between the | |
5 % time-series objects in the input analysis objects. CPSD is computed | |
6 % using a modified version of MATLAB's cpsd (>> help cpsd). | |
7 % | |
8 % CALL: b = cpsd(a1,a2,pl) | |
9 % | |
10 % INPUTS: aN - input analysis objects (two) | |
11 % pl - input parameter list | |
12 % | |
13 % OUTPUTS: b - output analysis object | |
14 % | |
15 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'cpsd')">Parameters Description</a> | |
16 % | |
17 % VERSION: $Id: cpsd.m,v 1.38 2011/04/08 08:56:13 hewitson Exp $ | |
18 % | |
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
20 | |
21 function varargout = cpsd(varargin) | |
22 | |
23 % Check if this is a call for parameters | |
24 if utils.helper.isinfocall(varargin{:}) | |
25 varargout{1} = getInfo(varargin{3}); | |
26 return | |
27 end | |
28 | |
29 import utils.const.* | |
30 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
31 | |
32 if nargout == 0 | |
33 error('### cpsd cannot be used as a modifier. Please give an output variable.'); | |
34 end | |
35 | |
36 % Collect input variable names | |
37 in_names = cell(size(varargin)); | |
38 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
39 | |
40 % Collect all AOs | |
41 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
42 | |
43 % Apply defaults to plist | |
44 pl = applyDefaults(getDefaultPlist, varargin{:}); | |
45 | |
46 % Throw an error if input is not two AOs | |
47 if numel(as) ~= 2 | |
48 error('### cpsd only accepts two inputs AOs.'); | |
49 end | |
50 | |
51 % Compute cross-spectrum with xspec | |
52 bs = xspec(as, pl, 'cpsd', getInfo, ao_invars); | |
53 | |
54 % Set output | |
55 varargout{1} = bs; | |
56 | |
57 end | |
58 | |
59 %-------------------------------------------------------------------------- | |
60 % Get Info Object | |
61 %-------------------------------------------------------------------------- | |
62 function ii = getInfo(varargin) | |
63 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
64 sets = {}; | |
65 pl = []; | |
66 else | |
67 sets = {'Default'}; | |
68 pl = getDefaultPlist(); | |
69 end | |
70 % Build info object | |
71 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: cpsd.m,v 1.38 2011/04/08 08:56:13 hewitson Exp $', sets, pl); | |
72 ii.setModifier(false); | |
73 ii.setArgsmin(2); | |
74 end | |
75 | |
76 %-------------------------------------------------------------------------- | |
77 % Get Default Plist | |
78 %-------------------------------------------------------------------------- | |
79 | |
80 function plout = getDefaultPlist() | |
81 persistent pl; | |
82 if ~exist('pl', 'var') || isempty(pl) | |
83 pl = buildplist(); | |
84 end | |
85 plout = pl; | |
86 end | |
87 | |
88 function pl = buildplist() | |
89 | |
90 % General plist for Welch-based, linearly spaced spectral estimators | |
91 pl = plist.WELCH_PLIST; | |
92 | |
93 end | |
94 |