Azimut angles comparison for wind (position differences in a vector)

Hi
I want to compare 2 datasets of azimutal wind directions and I want to know how to get the real resisdual between the 2 values being compared.
For example:
If I have a 345° modelised data (data1) and a 15° observed data (data2), I can't do data1 - data2 because it gives me 330° and not 30° who should be the real residual value.
I think it might work by calculating the umber of positions difference between the 2 data in a vector (to limit the number values of residual to 360), but I don't know how to do it.
I hope I'm clear !
Any other idea would be welcome !!
Thanks a lot

Answers (1)

Presumably you want a difference that lies between 0 and 180, as would be true for the inner angle of any triangle.
a = mod(data1-data2,360);
a = min(a,360-a);

Asked:

on 12 Jan 2015

Answered:

on 12 Jan 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!