cov
Covariance.
Syntax
Section titled “Syntax”V = cov(X)V = cov(X, Y)V = cov(X, Y, flag)Description
Section titled “Description”With one matrix argument X, returns the N×N covariance matrix of the columns of X (N = size(X, 2)). With two vector arguments, returns the scalar covariance between X and Y. The flag (0 for N-1 normalization, 1 for N) controls whether the unbiased or biased estimator is used.
Examples
Section titled “Examples”cov([1 2 3 4; 4 3 2 1]')% [1.6667 -1.6667; -1.6667 1.6667]