Operators#

Arithmetic operators#

Operator

Description

Example

+

Addition

a + b Adds a and b.

-

Subtraction

a - b Subtracts b from a.

*

Matrix Multiplication

a * b Multiplies a and b.

.*

ExE Multiplication

a .* b Multiplies elements of a and b.

/

Matrix Division

a / b Computes the least squares solution if b is not square.

./

ExE Division

a ./ b Divides each element of a by the corresponding element of b.

.^

ExE Power

a .^ b Raises each element of a to the power of b.

'

Transpose

a' Transposes matrix a, swapping its rows with columns.

.'

Bookkeeping Transpose

a.' Transposes matrix a without conjugation, applicable to complex matrices.

=

Assignment

a = b Assigns b to a.

Relational operators#

Operator

Description

Example

.==

Element-by-Element Equality

a .== b Compares each element of a with b, resulting in a matrix of 1’s and 0’s.

==

Equality

a == b Returns a scalar 1 (true) if all elements of a and b are equal, otherwise 0 (false).

=

Inequality

a != b Returns a scalar 1 (true) if a and b are not equal, otherwise 0 (false).

.!=

Element-by-Element Inequality

a .!= b Compares each element of a with b, resulting in a matrix of 1’s and 0’s.

.>=

Element-by-Element Greater or Equal

a .>= b Compares each element of a with b, resulting in a matrix of 1’s and 0’s.

>=

Greater or Equal

a >= b Returns 1 (true) if all elements of a are greater than or equal to those of b, otherwise 0 (false).

.<=

Element-by-Element Less or Equal

a .<= b Compares each element of a with b, resulting in a matrix of 1’s and 0’s.

<=

Less or Equal

a <= b Returns a scalar 1 (true) if all elements of a are less than or equal to those of b, otherwise 0 (false).