Issue with atan2(.)
조회 수: 4 (최근 30일)
이전 댓글 표시
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
채택된 답변
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개)
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
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
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 Exchange에서 Install Products에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!