0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % LTFE implements transfer function estimation computed on a log frequency axis.
|
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: LTFE implements transfer function estimation computed on a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % log frequency axis. The estimate is done by taking
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 % the ratio of the CPSD between the two inputs, Sxy, divided by
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % the PSD of the first input, Sxx:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % Sxy / Sxx where x is the first input, y is the second input
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % CALL: b = ltfe(a1,a2,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % INPUTS: a1 - input analysis object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % a2 - input analysis object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % pl - input parameter list
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % OUTPUTS: b - output analysis object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'ltfe')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % VERSION: $Id: ltfe.m,v 1.29 2011/04/08 08:56:16 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % References: "Improved spectrum estimation from digitized time series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % on a logarithmic frequency axis", Michael Troebs, Gerhard Heinzel,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % Measurement 39 (2006) 120-129.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 function varargout = ltfe(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % Check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 if nargout == 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 error('### tfe cannot be used as a modifier. Please give an output variable.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 % Collect input variable names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 in_names = cell(size(varargin));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 for ii = 1:nargin,in_names{ii} = inputname(ii);end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % Collect all AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 % Apply defaults to plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 pl = applyDefaults(getDefaultPlist, varargin{:});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % Throw an error if input is not two AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 if numel(as) ~= 2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 error('### ltfe only accepts two inputs AOs.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 % Compute transfer function with lxspec
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 bs = ao.lxspec(as, pl, 'tfe', getInfo, ao_invars);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % Set output
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 varargout{1} = bs;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % Get Info Object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 sets = {'Default'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 pl = getDefaultPlist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: ltfe.m,v 1.29 2011/04/08 08:56:16 hewitson Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 ii.setModifier(false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 ii.setArgsmin(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 % Get Default Plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 %--------------------------------------------------------------------------
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 function plout = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 persistent pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 if ~exist('pl', 'var') || isempty(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 pl = buildplist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 plout = pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 function pl = buildplist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 % General plist for Welch-based, log-scale spaced spectral estimators
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 pl = plist.LPSD_PLIST;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 % PARAMETERS:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 % 'Kdes' - desired number of averages [default: 100]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 % 'Jdes' - number of spectral frequencies to compute [default: 1000]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 % 'Lmin' - minimum segment length [default: 0]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 % 'Win' - the window to be applied to the data to remove the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 % discontinuities at edges of segments. [default: taken from
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 % user prefs]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % Only the design parameters of the window object are
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 % used. Enter either:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 % - a specwin window object OR
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 % - a string value containing the window name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 % e.g., plist('Win', 'Kaiser', 'psll', 200)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 % 'Olap' - segment percent overlap [default: -1, (taken from window function)]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 % 'Order' - order of segment detrending
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % -1 - no detrending
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 % 0 - subtract mean [default]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 % 1 - subtract linear fit
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 % N - subtract fit of polynomial, order N
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 % 'Variance' - computes transfer function variance.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 % 'yes' - compute tf variance [default]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 % 'no' - do not compute tf variance
|