plotting xcorr
조회 수: 6 (최근 30일)
이전 댓글 표시
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
채택된 답변
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]
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!