MATLAB Object-Oriented Programming

(Joyce) #1
Ensure that your class provides any error checking required to implement your class
design.

MATLAB Operators and Associated Functions


The following table lists the function names for MATLAB operators. Implementing
operators to work with arrays (scalar expansion, vectorized arithmetic operations, and so
on), can also require modifying indexing and concatenation. Use the links in this table to
find specific information on each function.

Operation Method to Define Description
a + b plus(a,b) Binary addition
a - b minus(a,b) Binary subtraction
-a uminus(a) Unary minus
+a uplus(a) Unary plus
a.*b times(a,b) Element-wise multiplication
a*b mtimes(a,b) Matrix multiplication
a./b rdivide(a,b) Right element-wise division
a.\b ldivide(a,b) Left element-wise division
a/b mrdivide(a,b) Matrix right division
a\b mldivide(a,b) Matrix left division
a.^b power(a,b) Element-wise power
a^b mpower(a,b) Matrix power
a < b lt(a,b) Less than
a > b gt(a,b) Greater than
a <= b le(a,b) Less than or equal to
a >= b ge(a,b) Greater than or equal to
a ~= b ne(a,b) Not equal to
a == b eq(a,b) Equality
a & b and(a,b) Logical AND
a | b or(a,b) Logical OR
~a not(a) Logical NOT

17 Specialize Object Behavior

Free download pdf