How do I specify the ranges of atan2?

2 visualizaciones (últimos 30 días)
Fran
Fran el 12 de Abr. de 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

Respuestas (1)

Iman Ansari
Iman Ansari el 12 de Abr. de 2013
Editada: Iman Ansari el 12 de Abr. de 2013
I replaced x and y in atan2d:
[x,y]=meshgrid(1:-0.1:-1);
m = atan2d(x,-y)+180;
mesh(x,y,m)

Categorías

Más información sobre Numerical Integration and Differential Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by