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