0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 <h2>Description</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 The LTPDA method <a href="matlab:doc('ao/cohere')">ao/cohere</a> estimates the cross-coherence of time-series
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 signals, included in the input <tt>ao</tt>s following the Welch's averaged, modified periodogram method <a href="#references">[1]</a>.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 Data are windowed prior to the estimation of the spectra, by multiplying
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 it with a <a href="specwin.html">spectral window object</a>, and can be detrended by a polinomial of time in order to reduce the impact
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 of the border discontinuities. The window length is adjustable to shorter lenghts to reduce the spectral
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 density uncertainties, and the percentage of subsequent window overlap can be adjusted as well.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 <h2>Syntax</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 <div class="fragment"><pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 <br> b = cohere(a1,a2,pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 </pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 </div>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 <tt>a1</tt> and <tt>a2</tt> are the 2 <tt>ao</tt>s containing the input time series to be evaluated, <tt>b</tt> is the output object and
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 <tt>pl</tt> is an optional parameters list.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 <h2>Parameters</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 The parameter list <tt>pl</tt> includes the following parameters:</p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 <ul>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 <li> <tt>'Nfft'</tt> - number of samples in each fft [default: length of input data]
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 Notice: analyzing a single segment produces as a result an object full of 1!
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 A string value containing the variable 'fs' can
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 also be used, e.g., plist('Nfft', '2*fs') </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 <li> <tt>'Win'</tt> - the window to be applied to the data to remove the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 discontinuities at edges of segments. [default: taken from user prefs].<br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 The window is described by a string with its name and, only in the case of Kaiser window,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 the additional parameter <tt>'psll'</tt>. <br>For instance: plist('Win', 'Kaiser', 'psll', 200). </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 <li> <tt>'Olap'</tt> - segment percent overlap [default: -1, (taken from window function)] </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 <li> <tt>'Order'</tt> - order of segment detrending <ul>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 <li> -1 - no detrending </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 <li> 0 - subtract mean [default] </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 <li> 1 - subtract linear fit </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 <li> N - subtract fit of polynomial, order N </li> </ul> </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 <li><tt>'Navs'</tt> - number of averages. If set, and if Nfft was set to 0 or -1, the number of points for each window will be calculated to match the request. [default: -1, not set] </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 <li><tt>'Times'</tt> - interval of time to evaluate the calculation on. If empty [default], it will take the whole section.</li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 <li><tt>'Type'</tt> - type of scaling of the coherence function. Choose between:</li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 <ul>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 <li> <tt>'C'</tt> - Complex Coherence Sxy / sqrt(Sxx * Syy) [default]</li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 <li> <tt>'MS'</tt> - Magnitude-Squared Coherence (abs(Sxy))^2 / (Sxx * Syy) </li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 </ul>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 </ul>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 The length of the window is set by the value of the parameter <tt>'Nfft'</tt>, so that the window
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 is actually rebuilt using only the key features of the window, i.e. the name and, for Kaiser windows, the PSLL.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 <p>As an alternative to setting the number of points <tt>'Nfft'</tt> in each window, it's possible to ask for a given number of coherence estimates by setting the <tt>'Navs'</tt> parameter, and the algorithm takes care of calculating the correct window length, according to the amount of overlap between subsequent segments.</p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 <table cellspacing="0" class="note" summary="Note" cellpadding="5" border="1">
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 <tr width="90%">
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 <td>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 If the user doesn't specify the value of a given parameter, the default value is used.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 </td>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 </tr>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 </table>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 The function makes cross-coherence estimates between the 2 input <tt>ao</tt>s.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 If passing two identical objects or linearly combined signals, the output will be 1 at all frequencies. The same will happen if analyzing only a single window.</p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 <h2>Algorithm</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 The algorithm is based in standard MATLAB's tools, as the ones used by <a href="matlab:doc('pwelch')">pwelch</a>. The standard deviation of the mean is computed as <a href="#references">[2]</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 <div align="center">
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 <img src="images/cohere_sigma1.png" >
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 </div>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 where
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 <div align="center">
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 <img src="images/tfe_sigma2.png" >
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 </div>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 is the coherence function.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 <h2>Example</h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 <p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 Evaluation of the cross-coherence of two time-series represented by: a low frequency sinewave signal superimposed to
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 white noise and a linear drift, and a low frequency sinewave signal at the same frequency, phase shifted and with different
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 amplitude, superimposed to white noise.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 </p>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 <div class="fragment"><pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 <br> <span class="comment">% parameters</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 nsecs = 5000;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 fs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 nfft = 1000;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 <span class="comment">% build first signal components</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 x1 = ao(plist(<span class="string">'waveform'</span>,<span class="string">'sine wave'</span>,<span class="string">'f'</span>,0.1,<span class="string">'A'</span>,1,<span class="string">'nsecs'</span>,nsecs,<span class="string">'fs'</span>,fs,<span class="string">'yunits'</span>,<span class="string">'m'</span>))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 x2 = ao(plist(<span class="string">'waveform'</span>,<span class="string">'noise'</span>,<span class="string">'type'</span>,<span class="string">'normal'</span>,<span class="string">'nsecs'</span>,nsecs,<span class="string">'fs'</span>,fs,<span class="string">'yunits'</span>,<span class="string">'m'</span>))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 x3 = ao(plist(<span class="string">'tsfcn'</span>, <span class="string">'t'</span>,<span class="string">'nsecs'</span>,nsecs,<span class="string">'fs'</span>,fs,<span class="string">'yunits'</span>,<span class="string">'m'</span>));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 <span class="comment">% add components</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 x = x1 + x2 + x3;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 <span class="comment">% build second signal components</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 y1 = ao(plist(<span class="string">'waveform'</span>,<span class="string">'sine wave'</span>,<span class="string">'f'</span>,0.1,<span class="string">'A'</span>,2,<span class="string">'nsecs'</span>,nsecs,<span class="string">'fs'</span>,fs,<span class="string">'phi'</span>,90));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 y2 = 4*ao(plist(<span class="string">'waveform'</span>,<span class="string">'noise'</span>,<span class="string">'type'</span>,<span class="string">'normal'</span>,<span class="string">'nsecs'</span>,nsecs,<span class="string">'fs'</span>,fs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 <span class="comment">% add components and set units</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 y = y1 + y2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 y.setYunits(<span class="string">'V'</span>);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 <span class="comment">% compute coherence</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 pl = plist(<span class="string">'win'</span>,<span class="string">'BH92'</span>,<span class="string">'nfft'</span>,nfft, <span class="string">'order'</span>,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 Cxy = cohere(x,y,pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 <span class="comment">%plot</span>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 iplot(Cxy);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 </pre>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 </div>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 <img src="images/cohere_1.png" border="3">
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 <h2><a name="references">References</a></h2>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 <br>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 <ol>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 <li> P.D. Welch, The Use of Fast Fourier Transform for the Estimation of Power Spectra: A Method Based on Time Averaging Over Short,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 Modified Periodograms, <i>IEEE Trans. on Audio and Electroacoustics</i>, Vol. 15, No. 2 (1967), pp. 70 - 73.</a></li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 <li> G.C. Carter, C.H. Knapp, A.H. Nuttall, Estimation of the Magnitude-Squared Coherence Function Via Overlapped Fast Fourier Transform Processing
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 , <i>IEEE Trans. on Audio and Electroacoustics</i>, Vol. 21, No. 4 (1973), pp. 337 - 344.</a></li>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 </ol>
|