This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Find logical exclusive-OR




C = xor(A,B) performs a logical exclusive-OR of arrays A and B and returns an array containing elements set to either logical 1 (true) or logical 0 (false). An element of the output array is set to logical 1 (true) if A or B, but not both, contains a nonzero element at that same array location. Otherwise, the array element is set to 0.


collapse all

Exclusive-OR Truth Table

Create a truth table for xor.

A = [true false; true false]
A =

     1     0
     1     0

B = [true true; false false]
B =

     1     1
     0     0

C = xor(A,B)
C =

     0     1
     1     0

Input Arguments

collapse all

A,B — Input arraysscalars | vectors | matrices | multidimensional arrays

Input arrays, specified as scalars, vectors, matrices, or multidimensional arrays. Inputs A and B must be the same size unless one is a scalar. A scalar value expands to be the same size as the other array.


Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char

Introduced before R2006a

Was this topic helpful?