Convert covariance matrix to correlation matrix

版本 1.0.0.0 (1.8 KB) 作者: Denis
Converts covariance matrix to correlation matrix setting exactly 1-s on its main diagonal
1.7K 次下载
更新时间 2008/7/10

查看许可证

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))).

引用格式

Denis (2024). Convert covariance matrix to correlation matrix (https://www.mathworks.com/matlabcentral/fileexchange/20630-convert-covariance-matrix-to-correlation-matrix), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2008a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Correlation and Convolution 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0