Finding a vector as a subset of an array
Afficher commentaires plus anciens
I have
a = [2 2];
b = [2 3];
How to find that 'b' contains all the elements of 'a' i.e. here two 2's. Here 'b' contains only one '2'.
1 commentaire
Bruno Luong
le 15 Déc 2018
so in the above example the result should be FALSE right?
Réponse acceptée
Plus de réponses (1)
madhan ravi
le 15 Déc 2018
Modifié(e) : madhan ravi
le 15 Déc 2018
a = [2 2];
b = [2 3];
idx=ismember(b,a);
all(idx) % if zero then b doesn't contain all the elements of a else vice versa
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!