abs

abs(X) returns the absolute value of each element of X.

Examples

> abs(-2)#

2
> abs([-2 3 -1.2])#

2            3          1.2
> abs(2 + i)#

2.23607
> x = -5 : 5

[x:1x11 double]

> plot(x, abs(x))

[ans:1x1 struct]

Resources

See also

angle | hypot | sign