setxor
Exclusive OR of two sets of data
Syntax
Description
returns the data of C = setxor(A,B)A and B that are not
in their intersection (the symmetric difference), with no repetitions. That is,
setxor returns the data that occurs in
A or B, but not both.
C is in sorted order.
If
AandBare tables or timetables, thensetxorreturns the rows that occur in one or the other of the two tables, but not both. For timetables,setxortakes row times into account to determine equality, and sorts the output timetableCby row times.
and
C = setxor(A,B,___,'rows')
treat each row of C = setxor(A,B,'rows',___)A and each row of B as
single entities and returns the rows of A and
B that are not in their intersection, with no
repetitions. You must specify A and B and
optionally can specify setOrder.
The 'rows' option does not support cell arrays, unless one
of the inputs is either a categorical array or a datetime array.
[
also returns index vectors C,ia,ib]
= setxor(___)ia and ib using
any of the previous syntaxes.
Generally, the values in
Care a sorted combination of the elements ofA(ia)andB(ib).If the
'rows'option is specified, thenCis a sorted combination of the rows ofA(ia,:)andB(ib,:).If
AandBare tables or timetables, thenCis a sorted combination of the rows ofA(ia,:)andB(ib,:).
Examples
Input Arguments
Output Arguments
Tips
To find the symmetric difference with respect to a subset of variables from a table or timetable, you can use column subscripting. For example, you can use
setxor(A(:,, wherevars),B(:,vars))varsis a positive integer, a vector of positive integers, a variable name, a cell array of variable names, or a logical vector. Alternatively, you can usevartypeto create a subscript that selects variables of a specified type.
Extended Capabilities
Version History
Introduced before R2006a