필터 지우기
필터 지우기

How to know which Signal is delayed !

조회 수: 1 (최근 30일)
Susan
Susan 2011년 8월 22일
Dear all, I have my code below for real data samples. I already tested the xcorr delay calculation method with different data and it produced the right answer but with the real data, I am not sure how to know after calculating the delay which of the two signal is the delayed version of the other?
x = sample1(:,1);
X = (x).';
y = sample2(:,1);
Y = (y).';
figure;
clf
subplot(3,1,1);
[xi,f]=ksdensity(X);
plot(f,xi);
line(repmat(X,2,1),repmat([0;0.1*max(xi)],1,length(X)),'color','r' );
subplot(3,1,2);
[xi,f]=ksdensity(Y);
plot(f,xi);
line(repmat(Y,2,1),repmat([0;0.1*max(xi)],1,length(Y)),'color','r' );
[Rxx,lags] = xcorr(X,Y);
[Z,delay] = max(Rxx);
lags(delay);

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 8월 22일
Susan, Others don't have your data sample1 and sample2 so won't be able to look at your data. Would the sign of lags(delay), be positive or negative, tell you whether Y is the delay of X, or X is the delay of Y?
y is 10 steps lag behind x, when running
[Rxx, lags] = xcorr(x, y);
[Y, I] = max(Rxx);
lags(I)
It returns -10, meaning y is 10 steps lag behind x
If you run
[Rxx, lags] = xcorr(y, x);%switch order of x and y
[Y, I] = max(Rxx);
lags(I)
It returns 10, meaning x is 10 steps ahead of y
  댓글 수: 4
Fangjun Jiang
Fangjun Jiang 2011년 8월 23일
You could visually inspect your data to get a sense whether the result is in the ballpark.
Susan
Susan 2011년 8월 23일
It would not be accurate but the fact that swapping both x,y gives different results I think its a sign the delay calculated is not right.. Any idea where I am going wrong?

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

카테고리

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