Skip to content

abs

Absolute value or modulus

abs(A)

  • It returns absolute value of each element of A.
  • If A is complex, it returns the modulus of each element of A.
  • The output has the same size as A.
  • It returns an empty array if A is empty.

Example 1: When a is real, abs(a) gives the absolute values.

a = [1 -1 0 1.2 -2.2];
abs(a)
ans =
1.000   1.000   0.000   1.200   2.200

Example 2: When a is complex, abs(a) gives the moduli.

a = [1+i -1-2i 0+0i 1.2 -2.2];
abs(a)
ans =
1.414   2.236   0.000   1.200   2.200