How to quickly find the indecis of an array in another array?
Show older comments
Dear All,
I have arrays A and B. I want to quickly find out the repeat entries of A in B without using intersect. For example, A = [21 32 33 41 28 91 30], and B = [32 67 41 91 100].
I want to find out the indecies of the entries in B also showing in array A. The solution is C =[1 3 4] whose correspoding entries are 32, 41 and 91 which are also entries in A.
I donot want to use intersect because it is slow in computation.
Thanks.
Benson
Accepted Answer
More Answers (1)
dpb
on 21 Jun 2021
>> [~,ia]=find(ismember(B,A))
ia =
1 3 4
>>
whether it is any faster I doubt, but it doesn't use intersect.
Whatever has to do the work, not sure there is magic bullet here.
1 Comment
Benson Gou
on 22 Jun 2021
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!