| Statistics Toolbox | Search  Help Desk |
| cov | See Also |
Syntax
C = cov(X)
C = cov(x,y)
Description
cov computes the covariance matrix. For a single vector, cov(x) returns a scalar containing the variance. For matrices, where each row is an observation, and each column a variable, cov(X) is the covariance matrix.
The variance function, var(X) is the same as diag(cov(X)).
The standard deviation function, std(X) is equivalent to sqrt(diag(cov(X))).
cov(x,y), where x and y are column vectors of equal length, gives the same result as cov([x y]).
Algorithm
The algorithm forcov is
[n,p] = size(X); X = X - ones(n,1)* mean(X); Y = X'*X/(n-1);
See Also
corrcoef, mean, std, var
xcov, xcorr in the Signal Processing Toolbox
cov is a function in MATLAB.