How MATLAB Represents Python Operators

MATLAB® supports the following overloaded operators.

Python® Operator SymbolPython MethodsMATLAB Methods
+ (binary) __add__, __radd__plus, +
- (binary) __sub__, __rsub__ minus, -
* (binary) __mul__, __rmul__mtimes, *
/__truediv__, __rtruediv__mrdivide, /
==__eq__eq, ==
>__gt__gt, >
<__lt__lt, <
!=__ne__ne, ~=
>=__ge__ge, >=
<=__le__le, <=
- (unary)__neg__uminus, -a
+ (unary)__pos__uplus, +a

The following Python operators are not supported.

Python Operator SymbolPython Method
%__mod__, __rmod__
**__pow__, __rpow__
<<__lshift__, __rlshift__
>>__rshift__, __rrshift__
&__and__, __rand__
^__xor__, __rxor__
|__or__, __ror__
// (binary) __floordiv__, __rfloordiv__
+= (unary) __iadd__
-= (unary) __isub__
*= (unary) __imul__
/= (unary) __itruediv__
//= (unary) __ifloordiv__
%= (unary) __imod__
**= (unary) __ipow__
<<= (unary) __ilshift__
>>= (unary) __irshift__
&= (unary) __iand__
^= (unary) __ixor__
!= (unary) __ior__
~ (unary) __invert__