corrcoef
Correlation coefficients
📝Syntax
R = corrcoef(M)
📥Input Arguments
Parameter Description
M a vector or matrix
📤Output Arguments
Parameter Description
R Correlation coefficients of M.
📄Description

R = corrcoef(M) returns the matrix of correlation coefficients for M, where the columns of M represent random variables and the rows represent observations.

The Pearson correlation coefficient between variables

$$X$$

and

$$Y$$

is:

$$r_{XY} = \frac{\text{cov}(X,Y)}{\sigma_X \sigma_Y} = \frac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum_{i=1}^n (x_i - \bar{x})^2 \sum_{i=1}^n (y_i - \bar{y})^2}}$$

where

$$\bar{x}$$

and

$$\bar{y}$$

are the sample means, and

$$\sigma_X$$

,

$$\sigma_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.

💡Examples
M = [4 -7 3; 1 4 -2; 10 7 9];
R = corrcoef(M)
🔗See Also
covmean
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub