Finding a vector as a subset of an array
Show older comments
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 Comment
Bruno Luong
on 15 Dec 2018
so in the above example the result should be FALSE right?
Accepted Answer
More Answers (1)
madhan ravi
on 15 Dec 2018
Edited: madhan ravi
on 15 Dec 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
1 Comment
Prasanna Venkatesh
on 16 Dec 2018
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!