How do I specify the ranges of atan2?

3 vues (au cours des 30 derniers jours)
Fran
Fran le 12 Avr 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

Réponses (1)

Iman Ansari
Iman Ansari le 12 Avr 2013
Modifié(e) : Iman Ansari le 12 Avr 2013
I replaced x and y in atan2d:
[x,y]=meshgrid(1:-0.1:-1);
m = atan2d(x,-y)+180;
mesh(x,y,m)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by