这个对我有用。
A=[1 0;1 0];
B=[1 1;0 0];
xor(A,B)
ans =
0 1
1 0
然而,当我尝试这个时......
XOR(A,B)
??? Undefined function or method 'XOR' for input arguments of type 'double'.
看到不同。关闭盖子以解决问题。
我认为产生歧义是因为他们的文档中使用了 MathWorks 约定。当他们在帮助中显示函数的名称时,他们使用全部大写。例如,这里是 xor 的帮助。
>> help xor
XOR Logical EXCLUSIVE OR.
XOR(S,T) is the logical symmetric difference of elements S and T.
The result is logical 1 (TRUE) where either S or T, but not both, is
nonzero. The result is logical 0 (FALSE) where S and T are both zero
or nonzero. S and T must have the same dimensions (or one can be a
scalar).
尽管如此,当您使用该函数时,您还是在函数名中使用小写字母。