Cross correlation of Matrix columns
Mostrar comentarios más antiguos
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 comentarios
Bob Thompson
el 18 de Abr. de 2018
Editada: Bob Thompson
el 18 de Abr. de 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
el 18 de Abr. de 2018
Editada: Antonis Asiminas
el 18 de Abr. de 2018
Bob Thompson
el 18 de Abr. de 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
el 18 de Abr. de 2018
Michael de la Maza
el 4 de Feb. de 2022
corrcoef(M)
Respuestas (0)
Categorías
Más información sobre Correlation and Convolution en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!