# Question:AutoCorrelation Maple vs MatLab

## Question:AutoCorrelation Maple vs MatLab

Maple

what is the difference between the autocorrelation function of Maple and MatLab function xcorr?

> N := 1024;
> f1 := 1;
> FS := 200;
> n := Vector([`\$`(0 .. N-1)]);
> x := evalf(`~`[sin](2*Pi*f1*n/FS));
> t := Vector([`\$`(1 .. N)]/FS);
> plot(t, x, axes = box, gridlines, color = blue, title = "Sinwave of frequency 1000Hz [FS=8000Hz]", labels = ["Time, [s]",

"Amplitude"], labeldirections = ["horizontal", "vertical"]);

http://www.mapleprimes.com/view.aspx?sf=134436/437460/sin_toAuto.jpg

> Rxx := Statistics[AutoCorrelation](x, 'scaling' = 'biased', 0 .. 2047);
> Rxx := ArrayTools[CircularShift](Rxx, (1/2)*op(1, Rxx));
> plot(Vector(op(1, Rxx), i->i), Rxx, axes = box, gridlines, color = blue, title = "Sinwave of frequency 1000Hz [FS=8000Hz]",

labels = ["Time, [s]", "Amplitude"], labeldirections = ["horizontal", "vertical"]);

http://www.mapleprimes.com/view.aspx?sf=134436/437460/AutoStat.jpg

maplesoftblog

http://www.mapleprimes.com/maplesoftblog/97099-More-Testing-Randomness-Autocorrelation

alias(FFT = DiscreteTransforms[FourierTransform], IFFT = DiscreteTransforms[InverseFourierTransform]);

AutoCorrFFT := proc (X, maxlag::posint := op(1, X))
local mu, N, M, Y, F, S, R, B;
mu := Statistics:-Mean(X);
N := op(1, X);
M := 2^ceil(log[2](2*N-1));
Y := Vector(M, `~`[`-`](X, mu), datatype = complex[8]);
F := FFT(Y);
S := Vector(M,i-> Im(F[i])^2+Re(F[i])^2, datatype = float[8]);
R := IFFT(S)[1 .. maxlag+1];
return Re(R)/abs(R[1]);
end proc;

http://www.mapleprimes.com/view.aspx?sf=134436/437460/AutoProc.jpg

MatLAb

http://www.mapleprimes.com/view.aspx?sf=134436/437460/AutoMatLab.jpg

As shown in the graphic outputs of the functions are different.

Gracias

﻿