How to know which Signal is delayed !
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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);
0 commentaires
Réponses (1)
Fangjun Jiang
le 22 Août 2011
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?
In my answer to your previous question, http://www.mathworks.com/matlabcentral/answers/13110-signal-processing
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 commentaires
Fangjun Jiang
le 23 Août 2011
You could visually inspect your data to get a sense whether the result is in the ballpark.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!