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 13:49:05 +0000 (UTC)
Organization: Xoran Technologies
Lines: 9
Message-ID: <io6u0h$kst$1@fred.mathworks.com>
References: <io4dgr$6m3$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1302788945 21405 172.30.248.45 (14 Apr 2011 13:49:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 14 Apr 2011 13:49:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:721882

"Sable Campbell" wrote in message <io4dgr$6m3$1@fred.mathworks.com>...
>
> I tried to unwrap this oscillating data coming out of my atan2 function, so that the output would extend beyond these limits, but it simply unwraps to an extremely large number.
> 
> Please advise.

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).