# How to convert [-90 90] range of elevation angel in imgradient3 to [0 , 180]?

24 views (last 30 days)
Negar Noorizadeh on 24 Oct 2018
Commented: Star Strider on 24 Oct 2018
Hi
I'm trying to use [Gmag,Gazimuth,Gelevation] = imgradient3(I) but the range of Gazimuth and Gelevation are [-180 180] and [-90 90], respectively.
I need Gazimuth and Gelevation to be in range of [0 360] and [0 180], respectively.
As I know, wrapTo360 Wrap angle in degrees to [0 360], So can I use this function to convert Gazimuth? Right?
Beside, wrapTo180 Wrap angle in degrees to [-180 180] but I need [0 180]. Can I convert [-90 90] to [0 180] as follow:
lambda = [-90 90];
positiveInput = (lambda > 0);
lambda = mod(lambda, 180);
lambda((lambda == 0) & positiveInput) = 180;
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Star Strider on 24 Oct 2018
Try this:
Angles180 = @(a) rem(180+a, 360)-90;
Result = Angles180([-90, 0, 90])
Result =
0 90 180
##### 5 CommentsShowHide 4 older comments
Star Strider on 24 Oct 2018
My pleasure.
If my Answer helped you solve your problem, please Accept it!

Sign in to comment.

### More Answers (1)

Jim Riggs on 24 Oct 2018
I think that if you want to convert the range -90 to +90 to 0 to 180, all you need to do is add 90 to each value. Similarly, if you have angles in the range -180 to +180 and you want them in 0 to 360, all you need to do is add 180 to the values.
##### 1 CommentShowHide None
Negar Noorizadeh on 24 Oct 2018
thank you Jim

Sign in to comment.

### Categories

Find more on Lengths and Angles in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by