| MATLAB Function Reference | ![]() |
Syntax
P = atan2(Y,X)
Description
P = atan2(Y,X)
returns an array P the same size as X and Y containing the element-by-element, four-quadrant inverse tangent (arctangent) of the real parts of Y and X. Any imaginary parts are ignored.
Elements of P lie in the closed interval [-pi,pi], where pi is MATLAB's floating- point representation of
. The specific quadrant is determined by sign(Y) and sign(X):

This contrasts with the result of atan(Y/X), which is limited to the interval
, or the right side of this diagram.
Examples
Any complex number z = x+iy is converted to polar coordinates with
r = abs(z)
theta = atan2(imag(z),real(z))
To convert back to the original complex number:
z = r *exp(i *theta)
This is a common operation, so MATLAB provides a function, angle(z), that simply computes atan2(imag(z),real(z)).
See Also
| atan, atanh | auread | ![]() |