R = corrcoef(M) returns the matrix of correlation coefficients forM, where the columns of M represent random variables and the rows represent observations.
The Pearson correlation coefficient between variables X
and Y
is: rXYโ=ฯXโฯYโcov(X,Y)โ=โi=1nโ(xiโโxห)2โi=1nโ(yiโโyหโ)2โโi=1nโ(xiโโxห)(yiโโyหโ)โ
where xห
and yหโ
are the sample means, and ฯXโ
, ฯYโ
are the standard deviations.
The correlation coefficient ranges from -1 to +1, where -1 indicates perfect negative correlation, +1 indicates perfect positive correlation, and 0 indicates no linear correlation.