Why do the ATAN2 and ANGLE functions in MATLAB 7.0 (R14) return different results from those in MATLAB 6.5.1 (R13SP1)?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I execute the following commands in both MATLAB 7.0 (R14) and 6.5.1 (R13SP1):
x1 = atan2(-[0 0], -[0 0])
x2 = angle([-0-0i -0-0i])
In MATLAB 6.5.1 (R13SP1) I receive "[0 0]" as the output, but in MATLAB 7.0 (R14), I receive "[pi pi]".
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 2009
This bug has been fixed in MATLAB 7.0.1 (R14SP1). For previous releases, read below for any possible workarounds:
This is due to a change in the way that the ATAN2 and ANGLE functions handle the special case of "negative zero" inputs in MATLAB 7.0 (R14).
To receive the same answers as in R13SP1, explicitly hardcode the output to zero for cases where both input arguments to ATAN2 are zero:
a = [5 4 0 -4];
b = [6 3 -0 2];
x=atan2(a,b);
x(a==0 & b==0) = 0;
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Performance and Memory en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!