0
$\begingroup$

I have done the computation of the autocorrelation of a sequence (vector), here called "frame", and I have plotted it. Here the code:

enter image description here

enter image description here

The resulting graph is: enter image description here

I do not understand the position of the peak in this graph: I know that the peak of the autocorrelation should be in the origin, why is it there?

$\endgroup$
1
$\begingroup$

The x axis is simply an index number, and this is showing your the correlation for leading and trailing shifts. The shift at index 80 is lag = 0, the origin you are interested in. Type help(xcorr) in Matlab to get further detail in how to return the lag. Following that, if you do the following you will get the result you are looking for:

r, lag = xcorr(frame, frame);
figure()
plot(lag, r) 

I did it as shown above to highlight how to return lag from xcorr specifically while minimizing change to your code, but xcorr(frame) will return the same result as xcorr(frame,frame) so can be further simplified for the case of autocorrelation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.