sign
Returns the sign of the value passed in.
Syntax
R = sign(x)
Inputs
- x
- Any valid scalar | vector | matrix.
Outputs
- R
- Resulting scalar | vector | matrix.
Examples
Simple scalar
input:
R = sign(4)
R = 1
Complex
input:
R = sign(1-2i)
R = 0.447214-0.894427i
Matrix
input:
R = sign([1,-2;0,1])
R = [ 1 -1 ; 0 1 ]
Complex matrix
input:
R = sign([1,-2;1+2i,-3i+1])
R = [ 1, -1; 0.447214 + 0.894427i, 0.316228-0.948683i]
Comments
The sign of a complex number is computed as z ./ abs(z)