MATLAB: Do the ATAN2 and ANGLE functions in MATLAB 7.0 (R14) return different results from those in MATLAB 6.5.1 (R13SP1)

angleatan2fdlibmMATLABr14zero

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]".

Best Answer

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;