Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Oscillating Discontinuity in atan2
Date: Thu, 14 Apr 2011 14:02:03 +0000 (UTC)
Organization: Xoran Technologies
Lines: 31
Message-ID: <io6uor$b3d$1@fred.mathworks.com>
References: <io4dgr$6m3$1@fred.mathworks.com> <io6u0h$kst$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1302789723 11373 172.30.248.35 (14 Apr 2011 14:02:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 14 Apr 2011 14:02:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:721885

"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 = 1e-20;

>> atan2(0,-1)

ans =

    3.1416

>> atan2(0 + tinyError,-1)

ans =

    3.1416

>> atan2( 0 - tinyError,-1)

ans =

   -3.1416