Negative zeros in Matlab

These values do not represent zeros. Instead, they are negative values which are very close to zero. The reason for getting these values and not simply zeros is due to approximations which are performed in the function implementation. According to Matlab documentation: "xcorr estimates the cross-correlation sequence of a random process".

In other words - the values which are displayed on the screen are just approximations for negative values.

In order to test this, you can change the display format of Matlab.

code:

format shortE;
xcorr([1 0 1 1], [0 1 1 0 0])

Result:

ans =

  Columns 1 through 5

 -6.2450e-017 -5.5511e-017  1.0000e+000  1.0000e+000  1.0000e+000

  Columns 6 through 9

  2.0000e+000  1.0000e+000  1.1102e-016  1.1796e-016

As you can see, the values in coordinates 1,2,8 and 9 are actually negative.