フィルターのクリア

How to compare 2 matrices and produce a 3rd matrix of percentage similarity?

1 回表示 (過去 30 日間)
Daniel Holden
Daniel Holden 2022 年 9 月 1 日
コメント済み: Daniel Holden 2022 年 9 月 2 日
I have two matrices of data that I need to compare. The actual dataset is rather large but for simplicity lets assume the first one is 3x3 and the second is 3x3. I want to 'slide' the first matrix over the second and produce a third matrix that contains data relating to the percentage match between the two matrices - I have illustrated an example of this below (only for the first 3 iterations, in total there would be six).
In the end I want a 3x3 matrix that contains percentages of match between the the black and red matrices for each iteration (X1, X2, X3 and so on) - with the sliding window there would be six total patterns which could populate the 3x3 matrix.
My MATLAB skills are still quite basic so any advice would be greatly appreciated!
Thank you!
  2 件のコメント
Matt J
Matt J 2022 年 9 月 1 日
編集済み: Matt J 2022 年 9 月 1 日
with the sliding window there would be six total patterns which could populate the 3x3 matrix.
Don't you mean 9? There are 9 sliding window positions that contain 4 or more points of overlap.
Daniel Holden
Daniel Holden 2022 年 9 月 2 日
Yes, I did mean 9. Apologies!

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

採用された回答

Matt J
Matt J 2022 年 9 月 1 日
編集済み: Matt J 2022 年 9 月 1 日
Perhaps with xcorr2 or normxcorr2?
X=rand(3); Y=rand(3);
C=normxcorr2(X,Y);
C=C(2:end-1,2:end-1)
C = 3×3
-0.0645 -0.3220 -0.4682 0.2891 -0.1946 -0.1773 0.3589 0.3744 -0.1858

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by