用MATLAB求两个矩阵的相关系数

来源:百度知道 编辑:UC知道 时间:2024/06/26 05:17:29
一个是九列67行的矩阵与一个1列67行的矩阵如何求相关系数,用MATLAB求,程序是什么

使用函数corrcoef即可求出,下面是一个例子:

help corrcoef

x = randn(30,4); % Uncorrelated data
x(:,4) = sum(x,2); % Introduce correlation.
[r,p] = corrcoef(x) % Compute sample correlation and p-values.
[i,j] = find(p<0.05); % Find significant correlations.
[i,j] % Display their (row,col) indices.

r =
1.0000 -0.3566 0.1929 0.3457
-0.3566 1.0000 -0.1429 0.4461
0.1929 -0.1429 1.0000 0.5183
0.3457 0.4461 0.5183 1.0000

p =
1.0000 0.0531 0.3072 0.0613
0.0531 1.0000 0.4511 0.0135
0.3072 0.4511 1.0000 0.0033
0.0613 0.0135 0.0033 1.0000

ans =
4 2
4 3
2 4
3 4