Convert covariance matrix to correlation matrix
by Denis
09 Jul 2008
(Updated 10 Jul 2008)
Converts covariance matrix to correlation matrix setting exactly 1-s on its main diagonal
|
Watch this File
|
| File Information |
| Description |
The function is "remix" of native matlab cov2corr() function, which produces correlation matrix with elements on its main diagonal slightly greater or less then 1. So it can't be used in various further computations, for example in squareform() function.
The problem can be resolved simply by setting all the diagonal elements to 1 (freaky way) or by using variance instead of std while computing correlation matrix (covariance(x,y)/sqrt(var(x)*var(y)) instead of covariance(x,y)/(std(x)*std(y))). |
| Required Products |
Financial Toolbox
|
| MATLAB release |
MATLAB 7.6 (R2008a)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (2) |
| 18 Jul 2008 |
denis k
|
|
|
| 15 Jul 2008 |
Dimitri Shvorob
|
|
|
|
Contact us