| Signal Processing Toolbox | Search  Help Desk |
| cov | See Also |
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
corrcoef |
Correlation coefficient matrix. |
mean |
Average value (see the online MATLAB Function Reference). |
median |
Median value (see the online MATLAB Function Reference). |
std |
Standard deviation (see the online MATLAB Function Reference). |
xcorr |
Cross-correlation function estimate. |
xcov |
Cross-covariance function estimate (equal to mean-removed cross-correlation). |