|MATLAB Function Reference|
C = cov(x)
x is a vector returns the variance of the vector elements. For matrices where each row is an observation and each column a variable,
cov(x) is the covariance matrix.
diag(cov(x)) is a vector of variances for each column, and
sqrt(diag(cov(x))) is a vector of standard deviations.
C = cov(x,y),
y are column vectors of equal length, is equivalent to
cov removes the mean from each column before calculating the result.
The covariance function is defined as
where is the mathematical expectation and .
A = [-1 1 2 ; -2 3 1 ; 4 0 3]. To obtain a vector of variances for each column of
v with covariance matrix
The diagonal elements
C(i,i) represent the variances for the columns of
A. The off-diagonal elements
C(i,j) represent the covariances of columns
xcov in the Signal Processing Toolbox