Symbolic fourquadrant inverse tangent
atan2(Y,X)
atan2(
computes
the fourquadrant inverse tangent (arctangent) of Y
,X
)Y
and X
.
If Y
and X
are vectors or
matrices, atan2
computes arctangents element by
element.

Symbolic number, variable, expression, function. The function
also accepts a vector or matrix of symbolic numbers, variables, expressions,
functions. If 

Symbolic number, variable, expression, function. The function
also accepts a vector or matrix of symbolic numbers, variables, expressions,
functions. If 
Compute the arctangents of these parameters. Because these numbers are not symbolic objects, you get floatingpoint results.
[atan2(1, 1), atan2(pi, 4), atan2(Inf, Inf)]
ans = 0.7854 0.6658 0.7854
Compute the arctangents of these parameters which are converted to symbolic objects:
[atan2(sym(1), 1), atan2(sym(pi), sym(4)), atan2(Inf, sym(Inf))]
ans = [ pi/4, atan(pi/4), pi/4]
Compute the limits of this symbolic expression:
syms x limit(atan2(x^2/(1 + x), x), x, Inf) limit(atan2(x^2/(1 + x), x), x, Inf)
ans = (3*pi)/4 ans = pi/4
Compute the arctangents of the elements of matrices Y
and X
:
Y = sym([3 sqrt(3); 1 1]); X = sym([sqrt(3) 3; 1 0]); atan2(Y, X)
ans = [ pi/3, pi/6] [ pi/4, pi/2]
Calling atan2
for numbers (or vectors
or matrices of numbers) that are not symbolic objects invokes the MATLAB^{®} atan2
function.
If one of the arguments X
and Y
is
a vector or a matrix, and another one is a scalar, then atan2
expands
the scalar into a vector or a matrix of the same length with all elements
equal to that scalar.
Symbolic arguments X
and Y
are
assumed to be real.
If X = 0
and Y > 0
,
then atan2(Y,X)
returns pi/2
.
If X = 0
and Y < 0
,
then atan2(Y,X)
returns pi/2
.
If X = Y = 0
, then atan2(Y,X)
returns 0
.
For complex Z = X + Y*i
, the call atan2(Y,X)
is
equivalent to angle(Z)
.