필터 지우기
필터 지우기

xcorr

조회 수: 20 (최근 30일)
Padma
Padma 2011년 10월 28일
Hi
could someone please explain the xcorr function more in detail. I actually tried reading the content under the help section but i could not understand properly. In the statement, [c,lags] = xcorr(x,y), could you explain what exactly is 'c' and 'lags' and could you please take an example and explain the output clearly.I am a beginner to matlab, please help me get the concept clearly.

채택된 답변

Honglei Chen
Honglei Chen 2011년 10월 28일
C is the answer you get by dong the correlation and lags is the corresponding and what xcorr(A,B) does is really moving A around and see whether it matches up with B.
Let's use a simple example, A = [1 1] and B = [1 1]
In this case, to have non-zero correlation output, A can be moved back and force by one sample and still have some overlap with B.
So at lag = -1, you can imagine that
A: 1 1
B: 1 1
so C at this point is 1. Similarly for lag = 0, you have
A: 1 1
B: 1 1
so C at this point is 2. If you do this for every position, you get
C = [1 2 1]
lag = [-1 0 1]
i.e., if the lag is -1 (A move to the left), the correlation is 1, if A does not move, the correlation is 2, ...
From this result, A and B matches best at where the maximum of C occurs, which is lag = 0.
HTH

추가 답변 (0개)

카테고리

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