Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/tfe.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 % TFE estimates transfer function between time-series objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: TFE makes transfer function estimates of the time-series | |
5 % in the input analysis objects. The estimate is done by taking | |
6 % the ratio of the CPSD between the two inputs, Sxy, divided by | |
7 % the PSD of the first input, Sxx: | |
8 % Sxy / Sxx where x is the first input, y is the second input | |
9 % | |
10 % CALL: b = tfe(a1,a2,pl) | |
11 % | |
12 % INPUTS: a1 - input analysis object | |
13 % a2 - input analysis object | |
14 % pl - input parameter list | |
15 % | |
16 % OUTPUTS: b - output analysis object | |
17 % | |
18 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'tfe')">Parameters Description</a> | |
19 % | |
20 % VERSION: $Id: tfe.m,v 1.36 2011/04/08 08:56:13 hewitson Exp $ | |
21 % | |
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
23 | |
24 function varargout = tfe(varargin) | |
25 | |
26 % Check if this is a call for parameters | |
27 if utils.helper.isinfocall(varargin{:}) | |
28 varargout{1} = getInfo(varargin{3}); | |
29 return | |
30 end | |
31 | |
32 import utils.const.* | |
33 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
34 | |
35 if nargout == 0 | |
36 error('### tfe cannot be used as a modifier. Please give an output variable.'); | |
37 end | |
38 | |
39 % Collect input variable names | |
40 in_names = cell(size(varargin)); | |
41 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
42 | |
43 % Collect all AOs | |
44 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
45 | |
46 % Apply defaults to plist | |
47 pl = applyDefaults(getDefaultPlist, varargin{:}); | |
48 | |
49 % Throw an error if input is not two AOs | |
50 if numel(as) ~= 2 | |
51 error('### tfe only accepts two inputs AOs.'); | |
52 end | |
53 | |
54 % Compute transfer function with xspec | |
55 bs = xspec(as, pl, 'tfe', getInfo, ao_invars); | |
56 | |
57 % Set output | |
58 varargout{1} = bs; | |
59 | |
60 end | |
61 | |
62 %-------------------------------------------------------------------------- | |
63 % Get Info Object | |
64 %-------------------------------------------------------------------------- | |
65 function ii = getInfo(varargin) | |
66 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
67 sets = {}; | |
68 pl = []; | |
69 else | |
70 sets = {'Default'}; | |
71 pl = getDefaultPlist(); | |
72 end | |
73 % Build info object | |
74 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: tfe.m,v 1.36 2011/04/08 08:56:13 hewitson Exp $', sets, pl); | |
75 ii.setModifier(false); | |
76 ii.setArgsmin(2); | |
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 pl = buildplist() | |
91 | |
92 % General plist for Welch-based, linearly spaced spectral estimators | |
93 pl = plist.WELCH_PLIST; | |
94 | |
95 end | |
96 |