how to find the time lag in cross correlation

31 ビュー (過去 30 日間)
mustafa alnasser
mustafa alnasser 2014 年 5 月 9 日
回答済み: Naomi Krauzig 2019 年 12 月 12 日
Dear All;
I am trying to find time delay using cross correlation but it does not give the right answer
my code:
[acor1,lag1]=xcorr(EE1(:,1),EE2(:,1)); % Figure(1) [~,I] = max(abs(acor1)); timeDiff1 = lag1(I)
but the answer: timeDiff1 =
0
what is the problem?

回答 (2 件)

dpb
dpb 2014 年 5 月 9 日
xcorr returns a 2*M-1 cross-correlation sequence for a vector length M from lags [-M:M] w/ the zeroth-lag in the middle of the returned vector. The auto-correlation (0-lag) value is going to be the max() so you need to restrict the search to lags>=1 and as well look for the maximum away from the initial decaying self-correlation around zero that can be significant depending on the shape of the two signals.
And, of course, there's the "minor" detail that the maximum correlation may not reflect the desired lag if the two signals aren't particularly self-similar with a phase lag only the difference as opposed to some large feature in one or the other.

Naomi Krauzig
Naomi Krauzig 2019 年 12 月 12 日
in case this is stillan open question, there is actually a function to find the delay: d = finddelay(x,y).
otherwise [r,lags] = xcorr(x,y) also returns the lags at which the correlations are computed.

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by