bug in matlab 2010b, trig functions (cosd, sind etc.)

2 ビュー (過去 30 日間)
Yanai
Yanai 2011 年 3 月 27 日
results are not consistent:
cosd(zeros(1,10))
ans =
0 1 1 1 1 1 1 1 1 1

回答 (11 件)

David Collins
David Collins 2012 年 4 月 20 日
Clearing background variables seems to do the trick (R2010b. OS Win7 x64.)
>> sind(22)
ans =
-0.9272
>> clear all
>> sind(22)
ans =
0.3746

the cyclist
the cyclist 2011 年 3 月 27 日
That is not the result I get, but I am using 64-bit 2010b on a Mac, so maybe that explains the difference. I would contact support about this.

Jiro Doke
Jiro Doke 2011 年 3 月 27 日
What's your OS and machine type? I'm on 32-bit 2010b on Win7, and I get the correct result (different from yours). Just to make sure, what do you get when you type
which cosd
which zeros
Do you get the correct answer when you do this?
cos(zeros(1,10))
  2 件のコメント
Yanai
Yanai 2011 年 3 月 27 日
I use:
MATLAB Version 7.11.0.584 (R2010b)
Operating System: Microsoft Windows 7 Version 6.1 (Build 7600)
Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
cos(zeros(1,10)) return the right answer
built-in (C:\Program Files\MATLAB\R2010b\toolbox\matlab\elmat\zeros)
built-in (C:\Program Files\MATLAB\R2010b\toolbox\matlab\elfun\@double\cosd) % double method
and just to clarify, sind & tand have the same problem
Jiro Doke
Jiro Doke 2011 年 3 月 27 日
I agree with the cyclist and, I suggest contacting tech support:
http://www.mathworks.com/support/

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


Alan Jennings
Alan Jennings 2011 年 4 月 1 日
This happens to me to. Same built in function, operating system and Java. Took me a while to figure out why my results weren't lining up; especially since it works right for some values. Amost seems like it does sind() on the first one sometimes.
Didn't see anything in bug reports, so I'll put one in... Till then, I'll just use cos(deg2rad()). Seems to work. Actually, I'll do the conversion myself, since I'm still getting screwy results, sometimes.

Alan Jennings
Alan Jennings 2011 年 4 月 2 日
Checked it out on another Windows 7 system, identical version, operating system and Java information as above, and cosd works fine. So there must be something else than just that.

Alan Jennings
Alan Jennings 2011 年 4 月 5 日
Just tried it on the first machine again, and works fine. Maybe some delayed windows update? No idea.

MXM
MXM 2011 年 4 月 7 日
Exactly the same problem occurs here (intermittently).
Version 7.11.0.584 (R2010b), 64-bit on windows 7.

J
J 2012 年 3 月 13 日
Same annoying problem here. Stick with radians and pray it doesn't suffer a similar issue:
>> cosd(0)
ans =
1
>> cosd(0)
ans =
0
>> cosd(0)
ans =
0
>> ver
-------------------------------------------------------------------------------------
MATLAB Version 7.11.0.584 (R2010b)
MATLAB License Number: ###### [SCd censored license]
Operating System: Microsoft Windows 7 Version 6.1 (Build 7601: Service Pack 1)
Java VM Version: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
-------------------------------------------------------------------------------------

Aldin
Aldin 2012 年 3 月 13 日
The result is consistent for MATLAB 1.9. (R2009b)

Ivan
Ivan 2012 年 4 月 2 日
I have the same issue. R2010b. OS Win7 x64.

Jan
Jan 2012 年 4 月 20 日
It would be nice to have a list of all affected functions here. The title of this thread "(cosd, sind etc.)" implies, that further functions suffer from this bug.

製品

Community Treasure Hunt

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

Start Hunting!

Translated by