MATLAB Function Reference
  Go to function:
    Search    Help Desk 
atan2    Examples   See Also

Four-quadrant inverse tangent

Syntax

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

To convert back to the original complex number:

This is a common operation, so MATLAB provides a function, angle(z), that simply computes atan2(imag(z),real(z)).

See Also

atan, atanh Inverse tangent and inverse hyperbolic tangent

tan, tanh   Tangent and hyperbolic tangent



[ Previous | Help Desk | Next ]