This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Sign of real or complex value




sign(z) returns the sign of real or complex value z. The sign of a complex number z is defined as z/abs(z). If z is a vector or a matrix, sign(z) returns the sign of each element of z.


Signs of Real Numbers

Find the signs of these symbolic real numbers:

[sign(sym(1/2)), sign(sym(0)), sign(sym(pi) - 4)]
ans =
[ 1, 0, -1]

Signs of Matrix Elements

Find the signs of the real and complex elements of matrix A:

A = sym([(1/2 + i), -25; i*(i + 1), pi/6 - i*pi/2]);
ans =
[   5^(1/2)*(1/5 + 2i/5),                              -1]
[ 2^(1/2)*(- 1/2 + 1i/2), 5^(1/2)*18^(1/2)*(1/30 - 1i/10)]

Sign of Symbolic Expression

Find the sign of this expression assuming that the value x is negative:

syms x
assume(x < 0)
ans =

For further computations, clear the assumption:

syms x clear

Input Arguments

collapse all

Input specified as a symbolic number, variable, expression, function, vector, or matrix.

More About

collapse all

Sign Function

The sign function of any number z is defined via the absolute value of z:


Thus, the sign function of a real number z can be defined as follows:

sign(z)={1 if x<0  0 if x=0  1 if x>0


  • Calling sign for a number that is not a symbolic object invokes the MATLAB® sign function.

See Also

| | | |

Introduced in R2013a

Was this topic helpful?