setxor - Find set exclusive OR of two vectors

Syntax

c = setxor(A, B)
c = setxor(A, B, 'rows')
[c, ia, ib] = setxor(...)

Description

c = setxor(A, B) returns the values that are not in the intersection of A and B. Inputs A and B can be numeric or character vectors or cell arrays of strings. The resulting vector is sorted.

c = setxor(A, B, 'rows'), when A and B are matrices with the same number of columns, returns the rows that are not in the intersection of A and B.

[c, ia, ib] = setxor(...) also returns index vectors ia and ib such that c is a sorted combination of the elements c = a(ia) and c = b(ib) or, for row combinations, c = a(ia,:) and c = b(ib,:).

Examples

a = [-1 0 1 Inf -Inf NaN];
b = [-2 pi 0 Inf];
c = setxor(a, b)

c =
    -Inf  -2.0000  -1.0000   1.0000   3.1416   NaN

See Also

intersect, ismember, issorted, setdiff, union, unique

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS