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

Contact us at files@mathworks.com