Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
xcorr vs. xcov

Subject: xcorr vs. xcov

From: Rasmus

Date: 19 Dec, 2010 00:01:01

Message: 1 of 3

Hi there,

I have a little trouble figuring out what I'm doing wrong when using the xcorr and xcov functions in MATLAB. Mathematically, the auto-correlation xcorr(X) is just the normalized auto-covariance xcov(X), thus xcorr(X)=xcov(X)/var(X), but the two functions provide very different results, and not just an offset. The following code is used in the test

X = rand(100,1);
figure, hold on
y1 = xcov(X,'coeff');
plot(y1(100:end),'r')
y2 = xcorr(X,'coeff');
plot(y2(100:end),'b')

I have used the option 'coeff' to enable the two graphs to be compared. Does anyone have an explanation to the problem?

Thanks

Subject: xcorr vs. xcov

From: Bruno Luong

Date: 19 Dec, 2010 09:22:04

Message: 2 of 3

"Rasmus" <prof.rasmusolesen@gmail.com> wrote in message <iejhvt$gk3$1@fred.mathworks.com>...
> Hi there,
>
> I have a little trouble figuring out what I'm doing wrong when using the xcorr and xcov functions in MATLAB. Mathematically, the auto-correlation xcorr(X) is just the normalized auto-covariance xcov(X), thus xcorr(X)=xcov(X)/var(X), but the two functions provide very different results, and not just an offset. The following code is used in the test

Did you read the doc? xcov removes the mean, xcorr does not.

Bruno

Subject: xcorr vs. xcov

From: Rasmus

Date: 19 Dec, 2010 11:10:21

Message: 3 of 3

That was the thing I missed, thanks for the help

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us