How do I specify the ranges of atan2?

3 views (last 30 days)
Fran
Fran on 12 Apr 2013
Hello,
I would like to, based on a vector with points (0,0) and (x,y) where (x,y) is anywhere in the plane, to calculate the angle between that vector and the positive vertical Y-axis.
So, I would like that when the vector matches the positive Y, I get 0 degrees.
AND I would like that it increases when going counterclockwise. AND I would like that I have a range between 0 and 360 degrees, no minus or other values.
How to do this with atan2? I am having problems with it even though it's simple trigonometry. I'm trying to avoid using IF statements and such.
Any help would be appreciated.
Kind Regards,
Francesco

Answers (1)

Iman Ansari
Iman Ansari on 12 Apr 2013
Edited: Iman Ansari on 12 Apr 2013
I replaced x and y in atan2d:
[x,y]=meshgrid(1:-0.1:-1);
m = atan2d(x,-y)+180;
mesh(x,y,m)

Categories

Find more on Resizing and Reshaping Matrices 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!