| MATLAB Function Reference | Search  Help Desk |
| setdiff | Examples See Also |
Return the set difference of two vectors
c = setdiff(a,b) c = setdiff(A,B,'rows') [c,i] = setdiff(...)
c = setdiff(a,b)
returns the values in a that are not in b. The resulting vector is sorted is ascending order. In set theoretic terms, c = a - b. a and b can be cell arrays of strings.
c = (A,B,'rows')
when A and B are matrices with the same number of columns returns the rows from A that are not in B.
[c,i] = setdiff(...)
also returns an index vector index such that c = a(i) or c = a(i,:).
A = magic(5); B = magic(4); [c,i] = setdiff(A,B); c' = 17 18 19 20 21 22 23 24 25 i' = 1 10 14 18 19 23 2 6 15
intersect Set intersection of two vectors
ismember True for a set member
setxor Set exclusive-or of two vectors
union Set union of two vectors
unique Unique elements of a vector