atan2

Purpose

Four-quadrant inverse tangent.

Synopsis

P = atan2(Y,X)

Description

atan2(Y,X) returns a matrix P the same size as X and Y containing the element-by-element, four-quadrant arctangent of the real parts of Y and X. Any imaginary parts are ignored.

Elements of P are in the interval [-pi, pi]. The specific quartile is determined by sign(Y) and sign(X):

This contrasts with the result of atan(Y/X), which is limited to the interval [-pi/2, pi/2], or the right side of this diagram.

Examples

Any complex number z = x+iy can be written in polar coordinates with

r = abs(z)
theta = atan2(imag(z),real(z)) 
Then z is equal to

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

 abs, angle, cos, funm, sin, tan

(c) Copyright 1994 by The MathWorks, Inc.