Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@math/overlapCorr.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 % OVERLAPCORR Compute correlation introduced by segment overlapping | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % OVERLAPCORR Compute correlation introduced by segment overlapping in WOSA | |
4 % spectral estimations. It estimates the term contributing to the variance | |
5 % because of segment overlapping. | |
6 % | |
7 % CALL | |
8 % | |
9 % R = utils.math.overlapCorr(w,N,T) | |
10 % [R,n] = utils.math.overlapCorr(w,N,T) | |
11 % | |
12 % INPUT | |
13 % | |
14 % - w, window samples, Nsx1 double, Ns must be the effective length of the | |
15 % segments used for spectral estimation. E.g. For a periodogram Ns is equal | |
16 % to the length of the data series. For a WOSA estimation Ns is the length | |
17 % of each averaging segment. | |
18 % - N total length of data series, 1x1 double | |
19 % - navs, number of averages, 1x1 double | |
20 % | |
21 % REFERENCES | |
22 % | |
23 % D. B. Percival and A. T. Walden, Spectral Analysis for Physical | |
24 % Applications (Cambridge University Press, Cambridge, 1993) p 292. | |
25 % | |
26 % L Ferraioli 09-03-2011 | |
27 % | |
28 % $Id: overlapCorr.m,v 1.1 2011/03/28 16:37:23 luigi Exp $ | |
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
30 function varargout = overlapCorr(w,N,navs) | |
31 | |
32 Ns = numel(w); | |
33 % willing to work with columns | |
34 [nn,mm] = size(w); | |
35 if nn<mm | |
36 w = w.'; | |
37 end | |
38 | |
39 % make suaqre integrable | |
40 a = sqrt(sum(w.^2)); | |
41 w = w./a; | |
42 | |
43 n = floor((N-Ns)/(navs-1)); | |
44 win = [w; zeros((navs-1)*n,1)]; | |
45 | |
46 R = 0; | |
47 for kk=1:navs-1 | |
48 ew = zeros(size(win)); | |
49 ew(kk*n+1:kk*n+Ns) = win(1:Ns); | |
50 | |
51 R = R + (navs-kk)*abs(win.'*ew)^2; | |
52 end | |
53 R = R./navs^2; | |
54 | |
55 if nargout == 1 | |
56 varargout{1} = R; | |
57 else | |
58 varargout{1} = R; | |
59 varargout{2} = n; | |
60 end | |
61 | |
62 | |
63 end |