Issue with atan2(.)

38 visualizaciones (últimos 30 días)
Tatte Berklee
Tatte Berklee el 9 de Dic. de 2019
Comentada: Steven Lord el 9 de Abr. de 2021
Hi folks,
I have an issue with atan2(.) function in MATLAB.
Currently, I have an expression that spits out .06, denote this as X.
When I do atan2(X), I obtain 0, which is incorrect.
Is this just digit issue?
atan2(.06) is 0.0599281551 rad, of course, accorindg to Google.
I don't understand why it is doing this?
Please help me, thanks.

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Dic. de 2019
>> atan2(0.06)
Error using atan2
Not enough input arguments.
>> atan2(0,0.06)
ans =
0
atan(0.06)
ans =
0.0599281551212079
You are calling with the wrong arguments.
  1 comentario
Tatte Berklee
Tatte Berklee el 9 de Dic. de 2019
Thanks, actually the issue was that I had first argument value to be zero in atan2(,), so it spit out zero. I traced back why it is spitting out zero, and it turns out there is a pair of identical values.

Iniciar sesión para comentar.

Más respuestas (1)

Steven Lord
Steven Lord el 9 de Dic. de 2019
The atan2 function included in MATLAB requires exactly two input arguments. Therefore you're likely calling a different atan2.m function. Use the following command to determine where the other atan2 function lives and remove or rename it.
which -all atan2
In addition to the built-in atan2 function you may see other versions of atan2 in the toolbox subdirectory under matlabroot, depending on what products you have installed. Look for ones outside the toolbox subdirectory.
When I call the atan function (which accepts exactly one input argument) with 0.6 that works as I expected and returns the result you found using Google.
  2 comentarios
Siti Syukriah Khamdan
Siti Syukriah Khamdan el 9 de Abr. de 2021
Hi, i have the same problem with atan2. Usually the errors always occurrs while im using it inside loops.
I check as you suggest, and found other version of atan2 as shown below. Do i need to rename or remove all of it?
built-in (/usr/local/MATLAB/R2020b/toolbox/matlab/elfun/@double/atan2) % double method
built-in (/usr/local/MATLAB/R2020b/toolbox/matlab/elfun/@single/atan2) % single method
/usr/local/MATLAB/R2020b/toolbox/nnet/deep/@dlarray/atan2.m % dlarray method
/usr/local/MATLAB/R2020b/toolbox/parallel/parallel/@codistributed/atan2.m % codistributed method
/usr/local/MATLAB/R2020b/toolbox/parallel/gpu/@gpuArray/atan2.m % gpuArray method
/usr/local/MATLAB/R2020b/toolbox/symbolic/symbolic/@sym/atan2.m % sym method
Steven Lord
Steven Lord el 9 de Abr. de 2021
No. I advise you not to touch files in the toolbox folder under matlabroot unless directed to do so by Technical Support.
Show us the full and exact text of the error you receive (all the text displayed in red and/or orange) when you run your code. Show us a small sample of code that you run to generate those errors as well.

Iniciar sesión para comentar.

Categorías

Más información sobre Function Creation 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