Function File: xwrap = wrapToPi (x)

Wraps X into the [-pi to pi] interval

x: angle(s) in radians (single value, vector or ND-matrix).

xwrap: output value(s) in the range [-pi .. pi] radians. The interval [-pi .. pi] is a closed interval: values equal to negative odd multiples of -pi are mapped to -pi, values equal to an odd multiple of +pi are mapped to pi.

Example:

wrapToPi ([-3*pi, -pi, -pi-1, 0; pi-1, pi, pi+1, 3*pi])
ans =
 -3.14159  -3.14159   2.14159   0.00000
  2.14159   3.14159  -2.14159   3.14159

See also: wrapTo180, wrapTo360, wrapto2Pi.

Package: mapping