### Problem

Given two arrays A and B, determine whether B is subset of A.

### Solution

Combine ismember with all. Function `ismember(B, A)`

will return an array with all elements set to true if, and only if, all elements in B are in A (which means B is a subset of A). Thus, `all(ismember(B, A)) = true`

iff B is a subset of A.

### References

[1] http://stackoverflow.com/questions/3918993/an-efficient-code-to-determine-if-a-set-is-a-subset-of-another-set

[2] http://www.mathworks.com/help/techdoc/ref/ismember.html

[3] http://www.mathworks.com/help/techdoc/ref/all.html

Advertisements

the orders may be different

Is that a question?

The solution should work even if the relative order of the elements in A and B are different.