Info

此问题已关闭。 请重新打开它进行编辑或回答。

How do I do correlation coefficient within a matrix?

1 次查看(过去 30 天)
Hello!
So I understand how to use the built in correlation coefficient, but it does not work for me. My scenario is that I have a 76x4000 matrix, and I want to find the correlation coefficient among each of the 76 rows, so i = 1:76, j = 1:76.
The end result should be a 76x76 symmetric matrix with 1s in the diagonal line.
Thank you very much!
I already have some codes for it, but the results are evidently wrong because I compared it to how it should be.
function Z = correlationcoefficient(P)
Z = []
for i = 1:76
% T = [];
for j = 1:76
w = 0;
s = cov(P(i,:),P(j,:));
t = s(1,2);
u = std(P(i,:));
v = std(P(j,:));
w = t/(u*v);
Z(j,i) = w;
end
end
end

回答(0 个)

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by