MATLAB Answers

How to compute the correlation between two metrices of same dimenstion (correlation between a column of a matrix to corresponding column of other matrix)?

6 views (last 30 days)
Amit Arya
Amit Arya on 4 Sep 2021
Commented: Amit Arya on 7 Sep 2021
I have two matrix A and B. Both metrics are same dimenstion. I need to compute the correlation coefficient between [A(:,1), B(:,1)], [A(:,2), B(:,2)], ......., [A(:,n),B(:,n)]. It is a column of A to a corresponding a column in B. At the end I want the output like correlation cofficient of each column from A matrix to corresponding column of B matrix. How do I perform efficiently in MATLAB?

Accepted Answer

Ive J
Ive J on 4 Sep 2021
A = rand(10, 3);
B = rand(10, 3);
R = diag(corr(A, B))
R = 3×1
0.2872 0.3099 0.1910

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by