Issue with atan2(.)

39 ビュー (過去 30 日間)
Tatte Berklee
Tatte Berklee 2019 年 12 月 9 日
コメント済み: Steven Lord 2021 年 4 月 9 日
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.

採用された回答

Walter Roberson
Walter Roberson 2019 年 12 月 9 日
>> 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 件のコメント
Tatte Berklee
Tatte Berklee 2019 年 12 月 9 日
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.

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2019 年 12 月 9 日
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 件のコメント
Siti Syukriah Khamdan
Siti Syukriah Khamdan 2021 年 4 月 9 日
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 2021 年 4 月 9 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by