How can I find a correlation between two matrices
2 views (last 30 days)
Show older comments
Hi,
I am trying to find a correlation between two matrices. I want to know how to make use of the command corrcoef(x,y). Or any other command would also be good.
I have following data - x - is a 35 by 1000 matrix, y- is a 13 by 1000 matrix. I want to find a sorted order of correlation between rows from x (i.e. 35) with each row in element in y (13 in my case) for all the 1000 columns.
So for example, it could be like for the 1st row in y would be correlated to say 10 rows in x and the rest could be uncorrelated. So, I wish to find that set and what is the exact descending order for each row in x with y.
I have tried using the command corrcoef(x,y), but it is not giving me what I am looking for. I have also tried few other commands like corr(x,y).
Thanks, Adi.
1 Comment
Lalit Patil
on 5 Dec 2012
Two ways..
First short your string of first matrix ,both rows and columns, like cropping in image. then short your string of second matrix, both rows and columns. So, both matrix sizes will be same..
or
second do zero padding in one of the matrix so size will be same of both matrices, then do correlation..
Answers (1)
Andrei Bobrov
on 5 Dec 2012
one way:
out = corr( cell2mat(cellfun(@(x1)interp1(x1,linspace(1,size(x,1),size(y,1))),num2cell(x,1),'un',0)),y);
0 Comments
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!