MATLAB: Covariance

covarianceerror

Hi,
quick question: can someone confirm that Matlab doesn't give back correct results for 'cov ? Example is here: http://www.mathworks.ch/help/techdoc/ref/cov.html
I calculated by hand and excel. I think there's something. Need the covariance for the financial toolbox.
Thanks a lot Ben

Best Answer

Matrix A in the example has 3 rows which represents 3 observations. In your case,if you use: a) cov(A) this command will divide by 2 i.e (N-1), giving you 10.3333 for the first element in the covariance matrix.
b)cov(A,1) this command will divide by 3 i.e (N), giving you the same result as you obtain in Excel. Hope this helps.