MATLAB arrays support matrix operations and element operations. For example, M*N
and M.*N
. This is a quite intuitive way to distinguish the two di
No, unfortunately you cannot define new operators—you can only overload existing operators (with a few important exceptions, such as operator.
). Even then, it's typically only a good idea to overload operators for types which have very clear and uncontroversial existing semantics for a given operator—for instance, any type that behaves as a number is a good candidate for overloading the arithmetic and comparison operators, but you should make sure that operator+
doesn't, say, subtract two numbers.