abs

Purpose

Absolute value and string to numeric conversion.

Synopsis

Y = abs(X)

Description

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

If X is complex, abs(X) returns the complex modulus (magnitude):

abs(X) = sqrt(real(X).^2+imag(X).^2)
If X is a MATLAB string, abs(X) returns the numeric values of the ASCII characters in the string. The way the string prints changes; the internal representation does not.

Examples

abs(-5) = 5
abs(3+4i) = 5
abs('3+4i') = [51  32  43  32  52  105]

See Also

angle, setstr, sign, strings, unwrap

(c) Copyright 1994 by The MathWorks, Inc.