Documentation |
Set exclusive OR of two arrays
C = setxor(A,B) returns the data of A and B that are not in their intersection (the symmetric difference).
If A and B are numeric arrays, logical arrays, character arrays, categorical arrays, datetime arrays, duration arrays, or cell arrays of strings, then setxor returns the values that occur in A or B, but not both. The values of C are in sorted order.
If A and B are tables, then setxor returns the rows that occur in one or the other of the two tables, but not both. The rows of table C are in sorted order.
C = setxor(A,B,'rows') treats each row of A and each row of B as single entities and returns the rows of matrices A and B that are not in their intersection. The rows of C are 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.
[C,ia,ib] = setxor(A,B) also returns index vectors ia and ib.
If A and B are numeric arrays, logical arrays, character arrays, categorical arrays, datetime arrays, duration arrays, or cell arrays of strings, then C is a sorted combination of the elements A(ia) and B(ib).
If A and B are tables, then C is a sorted combination of the rows of A(ia,:) and B(ib,:).
[C,ia,ib] = setxor(___,setOrder) returns C in a specific order using any of the input arguments in the previous syntaxes. setOrder='sorted' returns the values (or rows) of C in sorted order. setOrder='stable' returns the values (or rows) of C in the same order as A and B. If no value is specified, the default is 'sorted'.