Cross Correlation

조회 수: 11 (최근 30일)
Nithin
Nithin 2011년 10월 16일
What does the function xcorr(x,y) actually do? Is it just a multiplication of Xm+n and Yn ? If so, why does the result matrix have 2N-1 elements while X & Y have N elements? How do I conclude if there is correlation among X & Y from the result? Thanks

채택된 답변

Wayne King
Wayne King 2011년 10월 16일
xcorr computes the cross correlation sequence which is attained by shifting one sequence with respect to the other, complex conjugating it, taking the element by element product, and summing the result.
You typically want to compute the cross correlation sequence when you want to compute the "correlation" between a time series and shifted versions of another series.
For example, the following shows that y is a delayed version of x and the delay is 5 samples.
rng default;
x = randn(10,1);
y = [zeros(5,1); x];
[C,lags] = xcorr(y,x);
stem(lags,C);
Perhaps what you want is corrcoef() to compute the correlation between two random vectors?
  댓글 수: 2
Nithin
Nithin 2011년 10월 16일
Hi, Thanks for your reply. I am looking to do a cross correlation between velocity and its corresponding acceleration with a delay. Or velocity with a shifted velocity. In either case, I do not know how to conclude if there exists a correlation between the two time series
Wayne King
Wayne King 2011년 10월 16일
By the way, by default xcorr computes the cross correlation at 2*N-1 lags. If x and y are both length 3 for example, the lags run from:
-2,-1,0,1,2. You can specify the maxlag to be something less than that. See the help.

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

추가 답변 (1개)

Wayne King
Wayne King 2011년 10월 16일
velocity with a shifted velocity will definitely work with xcorr. Since acceleration is the derivative of velocity, if you have acceleration with a delay, you'll have to get the derivative of the velocity vector first to use xcorr().
  댓글 수: 2
Nithin
Nithin 2011년 10월 16일
I have the derivative and even the delayed version of the same time series. But my question is, how can I decisively conclude if there is a correlation between the velocity and a delayed version of it? If there is correlation, what would quantify the extent of the correlation? Thanks again for your answers!
Wayne King
Wayne King 2011년 10월 16일
If they are the same length, then you can use the 'coeff' option and you will have a cross correlation that ranges from [-1, 1]. You can look at the lag at which the largest correlation coefficient occurs and what it's value is.

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

카테고리

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