Skip to content

sign

Sign of real number

sign(A)

  • It returns the sign of each element of A.
  • It returns -1, 0, 1, and NaN if an element of A is negative, zero, positive, and NaN, respectively.
  • The output has the same size as A.
  • It returns an empty array if A is empty.

Example 1: Signs of zero, positive and negative numbers.

sign(0)
sign(11.2)
sign(-3.22)
ans =
0.000

ans =
1.000

ans = 
-1.000