Finding a vector as a subset of an array
显示 更早的评论
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 个评论
Bruno Luong
2018-12-15
so in the above example the result should be FALSE right?
采纳的回答
更多回答(1 个)
madhan ravi
2018-12-15
编辑:madhan ravi
2018-12-15
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
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!