atan2
Symbolic four-quadrant inverse tangent
Syntax
Description
Examples
Four-Quadrant Inverse Tangent for Numeric and Symbolic Arguments
Compute the arctangents of these parameters. Because these numbers are not symbolic objects, you get floating-point 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]
Limit of Four-Quadrant Inverse Tangent
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
Four-Quadrant Inverse Tangent of Array Input
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]
Input Arguments
More About
Tips
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
andY
is a vector or a matrix, and another one is a scalar, thenatan2
expands the scalar into a vector or a matrix of the same length with all elements equal to that scalar.Symbolic arguments
X
andY
are assumed to be real.If
X = 0
andY > 0
, thenatan2(Y,X)
returnspi/2
.If
X = 0
andY < 0
, thenatan2(Y,X)
returns-pi/2
.If
X = Y = 0
, thenatan2(Y,X)
returns0
.
Alternatives
For complex Z = X + Y*i
, the call atan2(Y,X)
is
equivalent to angle(Z)
.