Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How do I do correlation coefficient within a matrix?

1 visualizzazione (ultimi 30 giorni)
Lakyn
Lakyn il 25 Ago 2016
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by