# Transform angles that are -180 to +180 to angles that are in the 0-360 degree range?

51 views (last 30 days)

Show older comments

Kylie Davis
on 1 Jun 2016

Answered: theodore panagos
on 5 Dec 2018

### Accepted Answer

Star Strider
on 1 Jun 2016

This is my little anonymous function that I use for such problems:

Angles360 = @(a) rem(360+a, 360); % For ‘atan2d’

##### 3 Comments

Star Strider
on 1 Jun 2016

My pleasure!

It’s an anonymous function, and works like any other function. Just put it at the beginning of your code, then call it as:

Angles360 = @(a) rem(360+a, 360); % For ‘atan2d’

x = randi(9, 5, 1); % Create Data

y = randi(9, 5, 1); % Create Data

theta = atan2d(diff(y),diff(x));

theta360 = Angles360(theta);

### More Answers (1)

theodore panagos
on 5 Dec 2018

A formula to calculate an angle counter clockwise from x positive to 360 degrees:

f(x,y)=180-90*(1+sign(x))* (1-sign(y^2))-45*(2+sign(x)*sign(y)

-180/pi()*sign(x*y)*atan((abs(x)-abs(y))/(absx)+abs(y)))

##### 0 Comments

### See Also

### Community Treasure Hunt

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

Start Hunting!