FUNCTION REFERENCE

cov

Covariance.

Covariance.

Syntax

C = cov(x)

Syntax

C = cov(x, y)

Syntax

C = cov(x, flag)

Syntax

C = cov(x, y, flag)

For a vector it returns the variance. For a matrix, each row is an

observation and each column a variable; the result is the covariance matrix

of the columns. cov(x, y) treats x(:) and y(:) as two variables and returns

a 2-by-2 matrix. flag 0 (default) divides by N-1, flag 1 by N; one

observation divides by 1. cov([]) is NaN.

Example

cov([1 2; 3 4; 5 7])   % [4 5; 5 6.3333]

Differences from MATLAB: complex input is not supported yet.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.