필터 지우기
필터 지우기

Time delay - Cross Correlation Situation

조회 수: 1 (최근 30일)
Gabriel González
Gabriel González 2012년 7월 25일
Hi everyone...
I'm trying to calculate time delay using cross correlation but i don't know why i'm having this problem:
a=rand(1,10); %random excitation
x1=[a zeros(1,90)]; %Input signal
x2=[zeros(1,90) 0.8.*a]; %Output signal is a delayed version of x1 attenuated
Delay is equal to 90? right?
Well i should be able to calculate this delay from xc=xcorr(x1,x2);
but once i do this the peak is at xc(10) instead of be positioned at xc(190) now when i do xc=xcorr(x2,x1) peak is right positioned.
I don't know if I made myself clear, but i think that xc=xcorr(x1,x2) should be the correct way to do it....
Please help me here...

채택된 답변

Honglei Chen
Honglei Chen 2012년 7월 25일
The order basically determines which one is the reference, but you need to set your lag right. The delay between the two is basically 90, so one will give you 90 and the other one is -90. Try the following:
[xc,lags] = xcorr(x2,x1);
plot(lags,xc)
[xc,lags] = xcorr(x1,x2);
plot(lags,xc)
  댓글 수: 2
Gabriel González
Gabriel González 2012년 7월 26일
I understand, but still i'm not sure because if i do [xc,lags] = xcorr(x1,x2) i should have a delay equal to 90 not -90 which is what i got...
could I be conceptually wrong?
Honglei Chen
Honglei Chen 2012년 7월 26일
You may be using a different convention? The definition of the correlation in the doc page may clarify it for you.

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

추가 답변 (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