How can i find indices of constant elements between 2 arrays?

1 次查看(过去 30 天)
Hi, i have 2 enormous matrices A and B which are parameter relevant. With find() function i know which elements are non zero and with find(A-B) i know which elements are changed due to parameter. But how can i find out the indices of elements which remain constant?
  4 个评论
Jiahong Zou
Jiahong Zou 2023-5-31
编辑:Image Analyst 2023-5-31
Yeah sure. For example,
A = [1 2 0; 0 1 0; 5 0 8]
A = 3×3
1 2 0 0 1 0 5 0 8
B = [ 1 3 0; 0 4 0; 5 0 6]
B = 3×3
1 3 0 0 4 0 5 0 6
How to find the indices of bold 1 and 5 ? Zero elements must be not included, because i tried
[row_zero, column_zero] = find(~(A - B))
row_zero = 6×1
1 2 3 3 1 2
column_zero = 6×1
1 1 1 2 3 3
And it directly went out of memory.
Image Analyst
Image Analyst 2023-5-31
Exactly how big are your arrays? Hundreds of millions of elements or more?

请先登录,再进行评论。

采纳的回答

the cyclist
the cyclist 2023-5-31
Do you mean the non-zero elements that are the same between the two arrays?
A = [1 2 0; 0 1 0; 5 0 8];
B = [1 3 0; 0 4 0; 5 0 6];
[r,c] = find(A==B & A~=0)
r = 2×1
1 3
c = 2×1
1 1

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by