correlation matrix MATLAB

房东的猫 提交于 2020-01-04 14:29:13

问题


Do you know a matlab script that gets the correlation matrix of a set of data like numbe of columns=7, and rows = n>>7

 x1      x2      x3      x4     x5     x6      x7 

0.780   2.042   2.754   2.894  5.000  5.000  5.000
0.767   0.816   2.758   2.898  5.000  1.644  1.626
0.816   0.836   1.558   2.124  2.952  5.000  5.000
0.848   0.871   1.588   2.147  2.966  5.000  5.000
1.378   1.620   1.433   2.567  3.268  3.203  5.000
....

回答1:


Try corrcoef.

In general, you can find these sort of things immediately by searching the online help, for example via the convenient lookfor command:

>> lookfor correlation
corrcoef                       - Correlation coefficients.
msfuncorr                      - an M-S-function which performs auto- and cross-
...

>> help corrcoef
CORRCOEF Correlation coefficients.
   R=CORRCOEF(X) calculates a matrix R of correlation coefficients for
   an array X, in which each row is an observation and each column is a
   variable.

For instance

load file.txt
result= CORRCOEF(file);


来源:https://stackoverflow.com/questions/5054475/correlation-matrix-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!