'xcorr()' giving some negative values

2 Ansichten (letzte 30 Tage)
Biplab Roy
Biplab Roy am 29 Jan. 2017
Kommentiert: dpb am 31 Jan. 2017
I have two arrays A and B both having only positive values with some being zero. I am using c=xcorr(A,B) to get the cross correlation. I would expect the result to be all positive but getting some negative values. What is the reason?
  4 Kommentare
Biplab Roy
Biplab Roy am 31 Jan. 2017
Thanks all. As dpb correctly placed, is a classic example of some results being negative even though all inputs are positive. And i also feel it is the rounding error. Could not this be corrected?
dpb
dpb am 31 Jan. 2017
Sure
cor(cor<0)=0;
if you feel you must. But, in general, when you use floating point, rounding errors are inherent with the beastie.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by