From: "Benjamin Kraus" <>
Newsgroups: comp.soft-sys.matlab
Subject: Fit a linear function of two angles
Date: Mon, 30 Apr 2012 02:34:08 +0000 (UTC)
Organization: Boston University
Lines: 9
Message-ID: <jnktmv$663$>
Reply-To: "Benjamin Kraus" <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1335753248 6339 (30 Apr 2012 02:34:08 GMT)
NNTP-Posting-Date: Mon, 30 Apr 2012 02:34:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 630274
Xref: comp.soft-sys.matlab:766323

I've got two lists of angles (in radians, ranging from -pi to pi), that have a fixed offset from each other (plus a fair bit of noise).

angle1 = angle2+offset

I'm trying to calculate the offset. The problem is that both angles run from -pi to pi, so it isn't as simple as calling 'polyfit(angle1,angle2,1)', because I need to take into account that the angles wrap around. I know this is a simple problem, with a relatively simple solution, but it is eluding me at the moment.

Does anybody have any suggestions?

- Ben