How to change angles to 0 to 180
Show older comments
I have an array of angles ranging from [-180, 180]
please I want to change to [0, 180], how can I do this?
I have tried this code below but it's giving me [90, 180]
Angles180 = @(a) rem(180+a, 360)-90;
Result = Angles180([-90, 0, 90])
please how can I do this?
Accepted Answer
More Answers (2)
Image Analyst
on 29 May 2023
How about just adding 180 to all angles less than 0, so for example -135 becomes +45 degrees.
mask = angles < 180;
angles(mask) = angles(mask) + 180; % Only add 180 to negative angles.
2 Comments
DGM
on 29 May 2023
angles = mod(angles,180);
Image Analyst
on 29 May 2023
You say "What I wanted to do is I want to put all the following angles in the first quadrant ([0,90] so the ones that are already within 0 t 90 does not change and the ones that are with negative can taken as absolute."
Well, what about this:
angles = abs(angles);
???
Categories
Find more on Programming 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!