Quantcast

Documentation Center

  • Trial Software
  • Product Updates

atan2

Four-quadrant inverse tangent

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 Y and X, which must be real.

Elements of P lie in the closed interval [-pi,pi], where pi is the MATLAB® floating-point representation of π. atan uses sign(Y) and sign(X) to determine the specific quadrant.

atan2(Y,X) contrasts with atan(Y/X), whose results are limited to the interval [–π/2, π/2], 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))

For example,

z = 4 + 3i;
r = abs(z)
theta = atan2(imag(z),real(z))

r =
     5

theta =
    0.6435

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

To convert back to the original complex number

z = r * exp(i * theta)
z =

   4.0000 + 3.0000i

See Also

| | |

Was this topic helpful?