Path: news.mathworks.com!not-for-mail
From: "Sven" <sven.holcombe@gmail.deleteme.com>
Newsgroups: comp.soft-sys.matlab
Subject: angular comparison?
Date: Fri, 4 Sep 2009 18:37:01 +0000 (UTC)
Organization: University of Michigan
Lines: 13
Message-ID: <h7rmod$ii4$1@fred.mathworks.com>
Reply-To: "Sven" <sven.holcombe@gmail.deleteme.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1252089421 19012 172.30.248.38 (4 Sep 2009 18:37:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 4 Sep 2009 18:37:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1326470
Xref: news.mathworks.com comp.soft-sys.matlab:568456


Hi there,
I figured this would be a common problem, so there might be a simple trick already worked out.

How do I cluster variables that represent angles such that a value of 1 degree is deemed 'close' to 359 degrees?

Eg.

angles = rand(1,20)*360;

If I were working in a linear space a simple difference of two angles would give me their difference. But I think that my space is cyclic, so I'm not quite sure how to best have my space 'wrap around' from 360 back to 0, in preparation to do some clustering.

Thanks,
Sven.