! SIGN

SIGN

Syntax: vout = SIGN( v1, v2 )

The SIGN function is an element by element function that requires two (2) arguments. The arguments can be scalars, vectors, matrices or tensors, but vectors, matrices and tensors cannot be mixed, and all arrays must be the same size. Scalar arguments result in a scalar. A vector argument result in a vector with the same length as the argument, and matrix (tensor) arguments result in a matrix (tensor) with the same dimensions as the arguments.

arg 1  arg 2  result  definition
scalarscalarscalar  SIGN(a,b) = |a|*(sign of b)
vectorvectorvector  SIGN(x,y)[j] = |x[j]|*(sign of y[j])
scalarvectorvector  SIGN(a,x)[j] = |a|*(sign of x[j])
vectorscalarvector  SIGN(x,a)[j] = |x[j]|*(sign of a)
matrixmatrixmatrix  SIGN(m1,m2)[i,j] = |m1[i,j]|*(sign of m2[i,j])
scalarmatrixmatrix  SIGN(a,m)[i,j] = |a|*(sign of m[i,j])
matrixscalarmatrix  SIGN(m,a)[i,j] = |m[i,j]|*(sign of a)