MATLAB Functions Help Desk

setdiff

Purpose

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.

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 non-vector input array A is regarded as a column vector A(:).

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 ]