non-looping way to compare cellstr arrays of different sizes
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Suppose A = {'aa', 'kk', 'ccc'}, B = {'aa', 'bb', 'cc', 'dd', 'ee'}.
Is there a not-explicitly-looping way to return a logical array the same size as A that is 1 where an element of A is in B, 0 where it is not, e.g.,
"whereMember"(A,B) => [1 0 0]?
Thanks!
0 Kommentare
Akzeptierte Antwort
Oleg Komarov
am 24 Aug. 2011
A = {'aa', 'kk', 'ccc'};
B = {'aa', 'bb', 'cc', 'dd', 'ee'};
ismember(A,B)
4 Kommentare
Weitere Antworten (1)
David Goldsmith
am 24 Aug. 2011
7 Kommentare
Jan
am 25 Aug. 2011
@David: I've tried to let leo.org tell me, what affiliation is. Leo meant, that either somebody adopts me, or that it concerns my fatherhood. :-) If this means my company: I'm a freelancer. Perhaps my FEX author ID 15233 is helpful?
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!