Comparing two arrays of different length
98 次查看(过去 30 天)
显示 更早的评论
Hi,
I have two arrays like, A=[11 11 2 3; 5 2 6 9] and B=[11 3; 2 9]. I want to know the indices of array A where the column of B is equal to column of A. In this case, the indices are [2 4].
How can I do that?
Thanks in Advance.
0 个评论
采纳的回答
Giorgos Papakonstantinou
2014-11-17
You could this to find it:
idx = ismember(A', B', 'rows');
c = 1:size(A, 2);
d = c(idx); % is your answer
2 个评论
Josep Llobet
2021-10-5
indeed, maybe
ismember(0, unique(idx))
used with 0 (no-coincident) or 1 (coincident), may be useful.
Then combined with
length(unique(idx))
For to know about the totallity of coincidences
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!