Thread Subject: angular comparison?

Subject: angular comparison?

From: Sven

Date: 4 Sep, 2009 18:37:01

Message: 1 of 2

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.

Subject: angular comparison?

From: someone

Date: 4 Sep, 2009 18:51:00

Message: 2 of 2

"Sven" <sven.holcombe@gmail.deleteme.com> wrote in message <h7rmod$ii4$1@fred.mathworks.com>...
> 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.

To name a few,

You could compare the sin (or cosine) of the angles:
doc sind
doc cosd

Or, you could use the modulus function on the angles directly
doc mod
doc rem

I'm sure there are many other ways alao.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
angular comparison Sprinceana 4 Sep, 2009 15:58:37
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com