MATLAB Function Reference Previous page   Next Page
setdiff

Find 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 in ascending order. In set theory 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


Previous page  setappdata setfield Next page

© 1994-2005 The MathWorks, Inc.