corrcov

Convert covariance matrix to correlation matrix

Syntax

R = corrcov(C)
[R,sigma] = corrcov(C)

Description

R = corrcov(C) computes the correlation matrix R corresponding to the covariance matrix C. C must be square, symmetric, and positive semi-definite.

[R,sigma] = corrcov(C) also computes the vector of standard deviations sigma.

Examples

Use cov and corrcoef to compute covariances and correlations, respectively, for sample data on weight and blood pressure (systolic, diastolic) in hospital.mat:

load hospital
X = [hospital.Weight hospital.BloodPressure];
C = cov(X)
C =
  706.0404   27.7879   41.0202
   27.7879   45.0622   23.8194
   41.0202   23.8194   48.0590
R = corrcoef(X)
R =
    1.0000    0.1558    0.2227
    0.1558    1.0000    0.5118
    0.2227    0.5118    1.0000

Compare R with the correlation matrix computed from C by corrcov:

corrcov(C)
ans =
    1.0000    0.1558    0.2227
    0.1558    1.0000    0.5118
    0.2227    0.5118    1.0000

See Also

| | |

Was this topic helpful?