MATLAB Function Reference
  Go to function:
    Search    Help Desk 
setdiff    Examples   See Also

Return the set difference of two vectors

Syntax

Description

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,:).

Examples

See Also

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



[ Previous | Help Desk | Next ]