I think that you are simply confused with the covariance and covariance matrix, and the mathematical notation and the functional inputs of MATLAB look the same. In mathematics, cov(x,y) means the covariance of two variables x and y . MATLAB cov(x,y) computes the covariance matrix from x and y . Here cov is a function, and x and y are inputs.
To clarify, let me denote covariance in C MATLAB cov(x,y) returns the form matrix
C_xx C_xy C_yx C_yy
As RichC noted, you need off-diagonals, C_xy (note that C_xy=C_yx for real variables x and y ). The MATLAB script, which gives you the Pearson coefficient for the two variables x and y , is:
C=cov(x,y); p=C(2)/(std(x)*std(y));
abcd
source share