plotting xcorr

5 visualizaciones (últimos 30 días)
Diego
Diego el 28 de Dic. de 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 comentario
Diego
Diego el 28 de Dic. de 2011
Is this ok???
hold,plot([delay+1:length(seq2)+delay],seq2,'r');

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de Dic. de 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 comentario
Diego
Diego el 28 de Dic. de 2011
Thank you very much Walter.
Best,
Diego

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by