Cross Correlation - resulting vector not normalized properly? Help!
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am performing a cross correlation between two vectors (both functions of time). My goal is to obtain a resulting vector dependent on the time shift, that shows the correlation between the original two vectors (with the max value of the related vector as 1, minimum value of -1)
None of the options in xcorr are giving me this. The normalization options 'bias' and 'unbias' provide me with values not constrained to -1 < y < 1, and 'coeff' automatically assigns the most correlated time shift a value of 1. This isn't very helpful when I am trying to compare correlated vectors of many different inputs.
Does MatLab have a way to cross-correlate in the way I'm looking for?
Thanks!
2 Kommentare
Walter Roberson
am 30 Nov. 2011
I see from the status that you edited the question, Pocho, but I do not see any difference between your current wording and your previous wording?
Antworten (2)
Wayne King
am 29 Nov. 2011
The 'coeff' option only produces a value of 1 or -1 if a given time shift (lag) results in a perfect positive or negative correlation of two series.
It does not normalize on the maximum cross correlation value as you suggest. It does not assign the maximum cross correlation value 1. For example:
rng default;
x = randn(10,1);
y = randn(10,1);
[c,lags] = xcorr(x,y,'coeff');
max(abs(c))
On the other hand, create two sine waves where y is a delayed version of x (delayed by two samples).
n = 0:100;
x = cos(pi/4*n);
y = cos(pi/4*n-pi/2);
[c,lags] = xcorr(y,x,20,'coeff');
stem(lags(21:end),c(21:end));
Now the maximum is very close to 1 and occurs at lag 2 as expected.
Accordingly, if you obtain a cross correlation value of 1 with the 'coeff' option, that indicates that the two series are perfectly correlated at a given lag.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!