Correlation between two matrices with different number of rows and columns

조회 수: 30 (최근 30일)
Sophia
Sophia 2017년 6월 26일
댓글: Zsófia Jólesz 2020년 11월 11일
I have two matrices of different sizes. I want to calculate the spatial correlation between the two matrices but the matrices are of different sizes. Let's say matrix A of 119*177 size represent the ice drift and matrix B of size 760 *1120, But both data represent the same area at different spatial resolution. What is the best way to calculate the spatial correlation between the two.
  댓글 수: 1
Zsófia Jólesz
Zsófia Jólesz 2020년 11월 11일
I know it's been a while since you asked this, but is anyone here who knows how to make a C program for this? I think I have the program to calculate the correlation between two matrices with the same size, I just don't know how to overwrite this program to be able to count the corr. between different sized matrices.

댓글을 달려면 로그인하십시오.

답변 (3개)

ANKUR KUMAR
ANKUR KUMAR 2017년 10월 29일
편집: ANKUR KUMAR 2017년 10월 29일
Try interpolating it in between point to make them into the same dimension. 119*177 size represent the ice drift and matrix B of size 760 *1120 For example. try making your A matrix into the dimension of 760 * 1120. A having dimension 119*177. For the simplicity, lets say U*V
U1=linspace(min(U),max(U),760);
V1=linspace(min(U),max(V),1120);
Not interpolate these two new sets with the previous one. Example
A1=interp2(U,V,A,U1,V1)
It gives the output A1 having dimension 760*1120. Now you can easily use
corr2(A1,B)
It works, because both have the same dimension.

KSSV
KSSV 2017년 6월 27일
A = rand(119,177) ;
B = rand(760,1120) ;
%%Resize the matrices
% resize B to size of A
B = imresize(B,size(A)) ;
% Get corellation
r = corr2(A,B) ;
  댓글 수: 1
Sophia
Sophia 2017년 7월 5일
Instead of imresize i want to use some interpolation technique to solve this!

댓글을 달려면 로그인하십시오.


Andrei Bobrov
Andrei Bobrov 2017년 7월 5일
[m,n] = size(A);
[m1,n1] = size(B);
GI = griddedInterpolant({(1:m)',1:n},A);
AasB = GI({linspace(1,m,m1)',linspace(1,n,n1)});
r = corr2(B,AasB) ;

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by