Contents Previous Next Subchapters

Absolute Value Function
Syntax abs(value)
See Also sign , max , norm

Description
Returns the element-by-element absolute value of value, where value is an integer, real, double-precision, complex, or character matrix.

Example
     abs([-3, 4])
returns
     [ 3 , 4 ]

Complex Case
If value is a complex matrix, the return value is a double-precision matrix. Each element of the return value is the square root of the sum of the square of the real and imaginary parts of the corresponding element of value.
     abs([1. + 1i0, 1. - 1i0])
returns
     [ 1.41421 ,  1.41421 ]

Character Case
If value is a character matrix, the return value is an integer matrix. Each element of the return value is the numeric value of the ASCII characters in the matrix.
     abs("3 + 4i")
returns
     [ 51 , 32 , 43 , 32 , 52 , 105 ]