MATLAB Function Reference | Search  Help Desk |
xor | Examples See Also |
C = xor(A,
B)
C = xor(A,B)
performs an exclusive OR operation on the corresponding elements of arrays A
and B
. The resulting element C(i,j,...)
is logical true (1
) if A(i,j,...)
or B(i,j,...)
, but not both, is nonzero.A |
B |
C |
zero |
zero |
0 |
zero |
nonzero |
1 |
nonzero |
zero |
1 |
nonzero |
nonzero |
0 |
A = [0 0 pi eps]
and B = [0 -2.4 0 1]
, then
C = xor(A,B) C = 0 1 1 0To see where either
A
or B
has a nonzero element and the other matrix does not,
spy(xor(A,B))
&
Logical AND operator
|
Logical OR operator
all
Test to determine if all elements are nonzero
any
Test for any nonzeros
find
Find indices and values of nonzero elements