MATLAB Functions | Help Desk |
atan2
Four-quadrant inverse tangent
P = atan2(Y,X)
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 half-open interval
. 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.
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))
.
atan
, atanh
Inverse tangent and inverse hyperbolic tangent
tan
, tanh
Tangent and hyperbolic tangent