Cross correlation of Matrix columns
Afficher commentaires plus anciens
Hi,
thank you in advance for taking the time to read this. I have a problem for which I'm sure there is an easy answer but I cannot find it. I have a matrix M (n,m). Each column represents a different experimenter and each row different score. I would like to correlate the scores of each experimenter with the scores of themselves and all other experimenters, and create effectively a new matrix Cor (m,m). It's element of this matrix will be a single value corresponding to the Pearson correlation between each column pair. The diagonal (from m,1 to 1,m) will contain the auto correlations of all columns of matrix M. I understand that have this square matrix is redundant (mirror to the other half) but it looks good when shown as a coloured correlation Matrix. I think I can do that with several lines of code but I'd like to know if there's an easy way.
Best, Antonis
5 commentaires
Bob Thompson
le 18 Avr 2018
Modifié(e) : Bob Thompson
le 18 Avr 2018
What type of correlation are you looking to make? I know you mentioned "Pearson," but I don't know what that actually looks like.
Antonis Asiminas
le 18 Avr 2018
Modifié(e) : Antonis Asiminas
le 18 Avr 2018
Bob Thompson
le 18 Avr 2018
Ok, so your Cor (m*m) matrix is a collection of those single values? Why not just run a pair of for loops then?
for m1 = 1:size(M,2); % Create correlations for each experimenter
for m2 = 1:size(M,2); % Correlate against each experimenter
Cor(m2,m1) = corr(M(:,m1),M(:,m2));
end
end
If this isn't what you're looking for, please feel free to explain more.
Antonis Asiminas
le 18 Avr 2018
Michael de la Maza
le 4 Fév 2022
corrcoef(M)
Réponses (0)
Catégories
En savoir plus sur Correlation and Convolution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!