sign
Sign of real or complex value
Syntax
Description
Examples
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]); sign(A)
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) sign(5*x^3)
ans = -1
For further computations, clear the assumption on x
by
recreating it using syms
:
syms x
Input Arguments
More About
Tips
Calling
sign
for a number that is not a symbolic object invokes the MATLAB®sign
function.
Version History
Introduced in R2013a