Note: This page has been translated by MathWorks. Please click here

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Covariance

`C = cov(A)`

`C = cov(A,B)`

`C = cov(___,w)`

`C = cov(___,nanflag)`

returns
the covariance. `C`

= cov(`A`

)

If

`A`

is a vector of observations,`C`

is the scalar-valued variance.If

`A`

is a matrix whose columns represent random variables and whose rows represent observations,`C`

is the covariance matrix with the corresponding column variances along the diagonal.`C`

is normalized by the number of observations`-1`

. If there is only one observation, it is normalized by 1.If

`A`

is a scalar,`cov(A)`

returns`0`

. If`A`

is an empty array,`cov(A)`

returns`NaN`

.

returns
the covariance between two random variables `C`

= cov(`A`

,`B`

)`A`

and `B`

.

If

`A`

and`B`

are vectors of observations with equal length,`cov(A,B)`

is the`2`

-by-`2`

covariance matrix.If

`A`

and`B`

are matrices of observations,`cov(A,B)`

treats`A`

and`B`

as vectors and is equivalent to`cov(A(:),B(:))`

.`A`

and`B`

must have equal size.If

`A`

and`B`

are scalars,`cov(A,B)`

returns a`2`

-by-`2`

block of zeros. If`A`

and`B`

are empty arrays,`cov(A,B)`

returns a`2`

-by-`2`

block of`NaN`

.

Was this topic helpful?