Doubt about xcorr function

2 views (last 30 days)
Joao
Joao on 20 Jan 2015
Commented: Joao on 21 Jan 2015
Hello!
I have question about the xcorr function.
I have a vector with random bits 0s and 1s.
I do the autocorrelation of this vector and the output is the following:
However, shouldn't the autocorrelation for a random vector trace be like this:
sorry for my paint skills..
What is that space below the plot??? Is there any way to take it out?
Many thanks, João

Accepted Answer

Honglei Chen
Honglei Chen on 21 Jan 2015
You may want to use the 'unbiased' option in xcorr so the normalization is on the number of points used to compute the correlation. In addition, you may want to specify a maxlag because at the edge, there simply are not enough samples to get an accurate estimate. Here is a small example:
[c,l] = xcorr(rand91,1024)>0.5,500,'unbiased')
plot(l,c)
HTH

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!