Ismember function -- return all indexes, not just lowest?
Show older comments
According to the Matlab documentation,
[Lia,Locb] = ismember(A,B) returns an array, Locb, containing the lowest index in B for each value in A that is a member of B.
Is there a way to return an array (or matrix) containing all indexes in B for each value in A that is a member of B?
Accepted Answer
More Answers (1)
Jan
on 13 Jun 2013
Then the output can have different sizes for the different elements of A and a cell is required. What about a simple loop:
Out = cell(1, numel(A))
for iA = 1:numel(A)
Out{iA} = find(B == A(iA));
end
Categories
Find more on Creating and Concatenating Matrices 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!