MATLAB Answers

Issue with atan2(.)

2 ビュー (過去 30 日間)
Tatte Berklee
Tatte Berklee 2019 年 12 月 9 日
Answered: Steven Lord 2019 年 12 月 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.

  0 件のコメント

サインイン to comment.

採用された回答

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.

サインイン to comment.

More Answers (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.

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by