"Matt J" wrote in message <io6u0h$kst$1@fred.mathworks.com>...
> "Sable Campbell" wrote in message <io4dgr$6m3$1@fred.mathworks.com>...
>
> The ANGLE function is discontinuous in the neighbourhood of the negative real axis. This means that any numerical noise in the input X to angle(X) will can cause the values of X to jitter back and forth across the real axis with corresponding discontinuous jumps in angle(X) between pi and pi.
>
> Bottom line. You must insert code to detect when X gets close, within some tolerance, to the negative real axis and manually round it to a desired value (pi or pi).
========================
Sorry, you were talking about ATAN2 as opposed to ANGLE. But the same discontinuity is present in ATAN2, so the same remarks apply:
>> tinyError = 1e20;
>> atan2(0,1)
ans =
3.1416
>> atan2(0 + tinyError,1)
ans =
3.1416
>> atan2( 0  tinyError,1)
ans =
3.1416
