Statistics Toolbox    
cov

Covariance matrix.

Syntax

Description

C = cov(X) 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]).

The cov function is part of the standard MATLAB language.

Algorithm

The algorithm for cov is

See Also

corrcoef, mean, std, var

xcov, xcorr (Signal Processing Toolbox)


  corrcoef crosstab