MATLAB Answers

Correlation of rows of matrix B with rows of reference matrix A

15 ビュー (過去 30 日間)
Wookie
Wookie 2021 年 1 月 15 日
回答済み: Image Analyst 2021 年 1 月 16 日
I have a reference matrix A (10000 x 400) and a matrix B (10000 x 400).
I need to compare the first row of B to all the rows of A. I know the rest of the rows of B are going to be nearby (+/- 10) to what it found the strongest correlation for the first row. To make it more challenging, the row of B could shift in columns to get a higher correlation.
I started the following but i'm not sure if I'm in the right path as far as functions nor my results!
I need to get B to match A row by row and for it to be able to shift in columns if needed to achieve the highest correlation. And just getting the yshift and xshift of each row of B.
[r,c]=size(matA);
for i=1:r
x=crosscorr(matA(i,:),matB(i,:))
end

  0 件のコメント

サインインしてコメントする。

回答 (2 件)

KSSV
KSSV 2021 年 1 月 15 日
[r,c]=size(matA);
x = zeros(length(r),1) ;
for i=1:r
x(i) = corr(matA(i,:)',matB(i,:)') ;
end
[val,idx] = max(x)

  1 件のコメント

Wookie
Wookie 2021 年 1 月 15 日
Thank you for the reply and for changing it to corr function but this only outputs a single x for each "row". I would need to get information from what each row of B is correlated with what row of A in both x and y.

サインインしてコメントする。


Image Analyst
Image Analyst 2021 年 1 月 16 日
See my normalized cross corrrelation demo, attached.

  0 件のコメント

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by