Signal Processing Toolbox | ![]() ![]() |
Compute the covariance matrix.
Syntax
c=
cov(x) c=
cov(x,y)
Description
cov
computes the covariance matrix. If x
is a vector, c
is a scalar containing the variance. For an array 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.
cov(x)
is the zeroth lag of the covariance function, that is, the zeroth lag of xcov(x)/(n-1)
packed into a square array.
cov(x,y)
where x
and y
are column vectors of equal length is equivalent to cov([x y]))
, that is, it concatenates x
and y
in the row direction before its computation.
cov
removes the mean from each column before calculating the results.
The cov
function is part of the standard MATLAB language.
Algorithm
[n,p]=
size(x); x=
x-ones(n,1)*
(sum(x)/n); y=
x'*
x/(n-1);
See Also
|
Correlation coefficient matrix. |
|
Average value (see the MATLAB documentation). |
|
Median value (see the MATLAB documentation). |
|
Standard deviation (see the MATLAB documentation). |
|
Cross-correlation function estimate. |
|
Cross-covariance function estimate (equal to mean-removed cross-correlation). |
![]() | corrmtx | cplxpair | ![]() |