You can use the following operators when writing MathScript code in the MathScript Node or in a user-defined MathScript function.

Operator Name Description Example
= Assign Assigns values to variables. a = 1
: Colon Defines ranges. a = 1:10
; Semicolon Terminates statements or separates rows when defining a matrix.

c = 3;

b = [1; 2; 3]

, Comma Separates columns or terminates statements.

a = [1, 2]

b = [3, 4],

[] Brackets Define matrices and multiple outputs of a function. a = [1 2 3; 4 5 6]
() Parentheses Contain parameters of a function or indexes matrices in expressions.

a = sin(1)

c = b(2, 3)

~ Not Negates a logical expression.

a = [1, 0]

~(a)

+ Plus Adds. a + b
- Minus Subtracts or negates.

a - b

-a

* Multiplication Multiplies or performs matrix multiplication on matrices. a = 2* b
/ Division Divides or performs matrix division on matrices. a / b
.* Elementwise Multiplication Multiplies every element of a matrix with either a scalar or with every element of another matrix.

a = [1 2 3; 4 5 6]

b = [2 3 5; 7 9 1]

a .* b

./ Elementwise Division Divides every element of a matrix with either a scalar or with every element of another matrix. a ./ b
.' Transposition Transposes a matrix.

a = [1; 2; 3]

a .' b

.^ Elementwise Power Performs exponentiation of every element of a matrix with either a scalar or with every element of another matrix. a .^ b
' Conjugate Transposition Transposes the complex conjugate of a matrix and negates the imaginary parts.

a = [-i; 1 + i; 2 - 3i]

a' = [i, 1 - i, 2 + 3i]

^ Power Exponentiates. The result is a square matrix.

A = [1 + 3i, 5.6; -2.3, 8 - i]

B = 3

A ^ B

== Equals Compares equality. a == b
< Less Less than. a < b
<= Less or Equal Less than or equal to. a <= b
> Greater Greater than. a > b
>= Greater or Equal Greater than or equal to. a >= b
~= Not Equal Compares inequality. a ~= b
|| Or Performs logical OR (only when both arguments are scalar). The || operator uses short-circuit evaluation, which means, that the MathScript Node does not execute the second part of an expression if the first part is already TRUE. a || b
&& And Performs logical AND (only when both arguments are scalar). The && operator uses short-circuit evaluation, which means, that the MathScript Node does not execute the second part of an expression if the first part is already FALSE. a && b
| Elementwise Or Performs elementwise logical OR of every element of a matrix with either a scalar or with every element of another matrix. a | b
& Elementwise And Performs elementwise logical AND of every element of a matrix with either a scalar or with every element of another matrix. a & b