(unary)-

Additive inverse.

Syntax

-expr

Operand

expr
A valid scalar, vector, or matrix expression.

Example

Expression Result
-{3} -3
{-{1, 2, 3}} -1, -2, -3
{-{ {1, 2}, {-5, 3}}} {-1, -2}, {5, -3}

Comments

The unary operator generates the additive inverse (opposite in sign and equal in magnitude) of expr.

If expr is a scalar, the result is a scalar.

If expr is a vector or matrix, the result is a vector or matrix containing the additive inverses of each element in expr.