MATLAB Function Reference    
setdiff

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 = setdiff(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, ismember, issorted, setxor, union, unique


  set (COM) setfield