Matlab Operations

In MATLAB, “operation” does not refer to mappings in the broad sense; it means simple, direct, at-most-binary calculations expressed via operators or operator-equivalent functions. They fall into four kinds:

For the first three kinds, this note focuses on Matlab Operator usage. MATLAB has no operator for Matlab Set Operations, so that kind is implemented purely through functions.

Matlab Operator

Matlab Operator

Operator

Matlab Arithmetic Operations

SymbolRole
+Addition; Unary plus
-Subtraction; Unary minus
.*Element-wise multiplication
*Matrix multiplication
./Element-wise right division
/Matrix right division
.\Element-wise left division
\Matrix left division (also known as backslash)
.^Element-wise power
^Matrix power
.'Transpose
'Complex conjugate transpose

Matlab Relational Operations

SymbolRole
==Equal to
~=Not equal to
>Greater than
>=Greater than or equal to
<Less than
<=Less than or equal to

Matlab Logical Operations

SymbolRole
&Find logical AND
&&Find logical AND (with short-circuiting)
~Find logical NOT

String and Character Formatting

SymbolEffect on Text
''Single quotation mark
Cell delimiter
%{ %}Block comments that extend beyond one line
!Operating system command
?Metaclass for MATLAB class
~Argument placeholder to suppress specific input or output arguments
< &Specify superclasses
.?Specify fields of name-value structure when using function argument validation

Operator Precedence

  1. ()
  2. ~, sign +, -
  3. ^, .^, transpose ', .'
  4. .*, *, ./, /, .\, \
  5. +, -
  6. :
  7. <, <=, ==, >=, >, ~=
  8. &
  9. |
  10. &&
  11. ||
Link to original