plotting xcorr

조회 수: 6 (최근 30일)
Diego
Diego 2011년 12월 28일
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
Diego
Diego 2011년 12월 28일
Is this ok???
hold,plot([delay+1:length(seq2)+delay],seq2,'r');

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

채택된 답변

Walter Roberson
Walter Roberson 2011년 12월 28일
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
Diego
Diego 2011년 12월 28일
Thank you very much Walter.
Best,
Diego

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

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