Thanks in advance,
Silvia
'corrcoef' subtracts the mean value of each vector considered in the cross-correlation computation and 'xcorr' does not. Using the 'coeff' option with xcorr only scales the correlation values computed using xcorr.m but doesn't subtract the mean value. In statistical terms, corrcoef detrends the data before performing the correlation computation.
As you probably have already seen, there can be huge difference between the output these 2 approaches. If you subtract the mean from each vector before using xcorr, you will get the same (zero-lag) result as corrcoef:
>> test1
test1 =
1 2 4
>> test2
test2 =
9 1 1
>> xc1 = xcorr(test1,test2,'coeff')
xc1 =
0.0240 0.0719 0.3593 0.5270 0.8623
>> test3 = test1 - mean(test1)
test3 =
-1.3333 -0.3333 1.6667
>> test4 = test2 - mean(test2)
test4 =
5.3333 -2.6667 -2.6667
>> xc2 = xcorr(test3,test4,'coeff')
xc2 =
0.2520 0.3150 -0.7559 -0.4410 0.6299
>> xc3 = corrcoef(test1,test2)
xc3 =
1.0000 -0.7559
-0.7559 1.0000
>>
Hope this helps, good luck on your thesis...
Evan
"silvia_...@web.de B." <silvia_...@web.de> wrote in message <h7ln21$pnk$1...@fred.mathworks.com>...
Just wanted to add to my last post that:
xcov(test1,test2,'coeff')
also gives the same result as:
xcorr(test1 - mean(test1),test2 - mean(test2),'coeff').
ER
"silvia_...@web.de B." <silvia_...@web.de> wrote in message <h7ln21$pnk$1...@fred.mathworks.com>...