Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Set exclusive OR of two arrays

`C = setxor(A,B)`

`C = setxor(A,B,'rows')`

```
[C,ia,ib]
= setxor(A,B)
```

```
[C,ia,ib]
= setxor(A,B,'rows')
```

```
[C,ia,ib]
= setxor(___,setOrder)
```

```
[C,ia,ib]
= setxor(A,B,'legacy')
```

```
[C,ia,ib]
= setxor(A,B,'rows','legacy')
```

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

`A`

and`B`

are tables or timetables, then`setxor`

returns the rows that occur in one or the other of the two tables, but not both. For timetables,`setxor`

takes row times into account to determine equality, and sorts the output timetable`C`

by row times.

treats
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. `C`

is
in sorted order.

The `'rows'`

option does not support cell arrays,
unless one of the inputs is either a categorical array or a datetime
array.

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(:,`

, where),B(:,`vars`

))`vars`

is a positive integer, a vector of positive integers, a variable name, a cell array of variable names, or a logical vector. Alternatively, you can use`vars`

`vartype`

to create a subscript that selects variables of a specified type.

Was this topic helpful?