Effacer les filtres
Effacer les filtres

plotting xcorr

2 vues (au cours des 30 derniers jours)
Diego
Diego le 28 Déc 2011
Dear all, I found the following code in one of the posts for plotting the xcorr. I don't understand very well how to handle the plotting, I have to say. The thing is, the second plot is shifted to the left one unit. I can make it fit by adding 1 to the delay, but I think this is not appropriate since the delay between 2 equal sequences should be 0(???). I would appreciate if somebody can explain me how this works and what is the right way to make the 2 sequences fit. Thanks, Diego
MATLAB code
X1=xcorr(seq1,seq2,'coeff');
[m,d]=max(X1);
display(max(X1));
delay=d-max(length(seq1),length(seq2));
display(delay);
figure,plot(seq1);
hold,plot([delay:length(seq2)+delay-1],seq2,'r');
grid on
  1 commentaire
Diego
Diego le 28 Déc 2011
Is this ok???
hold,plot([delay+1:length(seq2)+delay],seq2,'r');

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 28 Déc 2011
plot(seq1) is implicitly plot(1:length(seq1), seq1) . And that starts at 1. A delay of 0 should thus start at position 1 if it is to match the first seq1 position, so you should indeed be adding 1 to your [delay:length(seq2)+delay-1]
  1 commentaire
Diego
Diego le 28 Déc 2011
Thank you very much Walter.
Best,
Diego

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by