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
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!