如何在MATLAB中使逻辑矩阵的XOR工作?

Gtk*_*ker 1 matlab xor

>> XOR(X,X)
??? Undefined function or method 'XOR' for input arguments of type 'logical'.
Run Code Online (Sandbox Code Playgroud)

为什么XOR不能用于逻辑矩阵?

我尝试了一个更简单的例子:

>> A=[1 0;1 0];
>> B=[1 1;0 0];

>> XOR(A,B)
??? Undefined function or method 'XOR' for input arguments of type 'double'.
Run Code Online (Sandbox Code Playgroud)

我该如何正确使用XOR

小智 8

这个对我有用.

A=[1 0;1 0];
B=[1 1;0 0];

xor(A,B)
ans =
     0     1
     1     0
Run Code Online (Sandbox Code Playgroud)

然而,当我尝试这个...

XOR(A,B)
??? Undefined function or method 'XOR' for input arguments of type 'double'.
Run Code Online (Sandbox Code Playgroud)

看到不同.保留上限以解决问题.

我认为由于其文档中使用的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).
Run Code Online (Sandbox Code Playgroud)

即使这样,当您使用该功能时,您也可以在功能名称中使用小写字母.