why are my cross correlation values so high?

조회 수: 64 (최근 30일)
Heidi Hirsh
Heidi Hirsh 2019년 9월 26일
댓글: Heidi Hirsh 2019년 10월 5일
I am trying to find the best lag for relating to vectors of data (attached in the mat files as vectors x and y). I want to do a cross correlation to actually calculate the best lag. I am using xcorr to look at the cross correlation values ( c ) for different lags. lag= -5 has the highest value but the correlations are all over 3000. This seems really high. Can anyone explain this value to me. I've read the documentation for xcorr and I'm lost.
[c,lags] = xcor(x,y)
  댓글 수: 8
Adam Danz
Adam Danz 2019년 9월 27일
Oops! I misread. Sorry.
Heidi Hirsh
Heidi Hirsh 2019년 10월 5일
No problem. I really appreciated your help! I am still not sure why the correlation outputs are so different between xcorr and crosscorr.

댓글을 달려면 로그인하십시오.

답변 (2개)

the cyclist
the cyclist 2019년 9월 26일
편집: the cyclist 2019년 9월 26일
The values are right in line with what I would expect. A typical value would be
(typical x value) * (typical y value) * (length of vectors)
so
5 * 8 * 78 = 3120
See the "More About" section of the documentation.
If you were expecting it to be normalized, then look at the scaleopt input.
  댓글 수: 1
Heidi Hirsh
Heidi Hirsh 2019년 9월 27일
Thank you! I did indeed want the normalized ('coeff') option!

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2019년 9월 27일
Cross correlation doesn't always have it's peak where the "lag" between two signals is, as a little thought will reveal. It shows you the sum of the multiplication of the overlapped terms as one signal slides past the other. For example if one signal has high values somewhere in one segment, but otherwise looks pretty much the same (just shifted), your peak correlation value won't be at the lag you think it should be. It might show you where the high values are, not where the bulk of the signal overlaps best.
There is another concept called normalized cross correlation you might want to look at. There is a 2-D version in the Image Processing Toolbox, normxcorr2(), and I attach an example for finding a template in a 2-D color image. I don't know if there is a 1-D version but often image processing functions will work on 1-D signals as well as 2-D signals.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by