How do I compute the correlation between corresponding rows of two matrices?
Ältere Kommentare anzeigen
I have two matrices, X and Y, which each have 60 columns and 10,000 rows.
I would like to create a vector R, such that the nth value of vector R represents the correlation between row n of matrix X and row n of matrix Y.
I have tried:
[R,pval] = corr(X',Y');
but this gives me R as a 10,000-by-10,000 matrix.
What am I doing wrong?
Akzeptierte Antwort
Weitere Antworten (2)
Von Duesenberg
am 11 Mai 2018
arrayfun(@(k) corr(A(k,:)', B(k,:)'), 1:10000, 'Uni', 1)
Shounak Shastri
am 11 Mai 2018
0 Stimmen
From what I know, Correlation Matrices are usually square. As in you have 10000 rows with 60 elements in each row. So if you take 1 row of dimension 1 x 60, the dimension of your corr matrix would be 60 x 60.
But in your example, you took a transpose. So, now the size of each row is 1 x 10000. And thus when you perform correlation on the rows, you would get a 10000 x 10000 matrix.
1 Kommentar
Michael Wolf
am 11 Mai 2018
Kategorien
Mehr zu Descriptive Statistics and Insights finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!