How to solve atan2 function Problem?

15 visualizaciones (últimos 30 días)
Javad
Javad el 4 de En. de 2014
Editada: Javad el 4 de En. de 2014
There is a problem with atan2. when the value reaches pi, the output returns to zero, While I would like to see the angles more than pi to infinity. How can I solve this? Thanks
  4 comentarios
Image Analyst
Image Analyst el 4 de En. de 2014
Let's look at the tangent of 60 and every 360 after that (for a while):
angles = 60:360:4000
tangents = tand(angles);
fprintf('%.3f', tangents);
now look at what it reports:
angles =
60 420 780 1140 1500 1860 2220 2580 2940 3300 3660
1.7321.7321.7321.7321.7321.7321.7321.7321.7321.7321.732
Now, if you were to take one of those numbers, say the 3rd 1.7321 number, how is the arctangent function supposed to know that it came from an angle of 780 , and not from 60, 420, or any of an infinite number of other possibilities that you passed it? Please tell me how the atand function should know.
Javad
Javad el 4 de En. de 2014
Editada: Javad el 4 de En. de 2014
that's right. Of course By the code I wrote above, display (not the result of atan2) has a range of 0 to 360 deg. however it disable displaying the negative angle.

Iniciar sesión para comentar.

Respuestas (3)

Roger Stafford
Roger Stafford el 4 de En. de 2014
It looks as though you need the 'unwrap' function:
http://www.mathworks.com/help/matlab/ref/unwrap.html
It depends on making adjustments to a sequence of angles which don't change by more than pi radians from one to the next. The function 'atan2' itself is limited to a range from -pi to +pi, though you can use the 'mod' function to adjust it to some other range which spans 2*pi, but there is no way of spanning more a 2*pi range without additional information beyond simply a pair of cartesian coordinates.

Mischa Kim
Mischa Kim el 4 de En. de 2014
Editada: Mischa Kim el 4 de En. de 2014
To make atan2 a proper, one-to-one (called bijective) function it -- by definition -- returns angular values between -pi and +pi. In other words, there is no solution to your problem, in general.
However, if you do have more information on your problem there might be ways to back out angular values greater than -pi and +pi.

Azzi Abdelmalek
Azzi Abdelmalek el 4 de En. de 2014
Editada: Azzi Abdelmalek el 4 de En. de 2014
What you are doing is not clear. But if you want to have angles more than pi, you have to add k*pi to the result given by atan2 which is in the interval [-pi pi]. The k depends on what you are doing.
The informations Y and X given to atan2 do not allow to know if the result is alpha or alpha+k*pi
  2 comentarios
Greg Heath
Greg Heath el 4 de En. de 2014
Do you mean alpha +/- 2*k*pi?
Azzi Abdelmalek
Azzi Abdelmalek el 4 de En. de 2014
Editada: Azzi Abdelmalek el 4 de En. de 2014
No, I mean alpha+k*pi ( k is a positive or negative integer)

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by