Help to understand a strange behaviour

1 回表示 (過去 30 日間)
Ivan
Ivan 2012 年 4 月 1 日
WTF is the following: (noticed ocationally)
>> clear
>> sind(30)
ans =
-0.8660
>> whos
Name Size Bytes Class Attributes
ans 1x1 8 double
after restart:
>> sind(30)
ans = 0.5000
(R2010b)
  5 件のコメント
Geoff
Geoff 2012 年 4 月 1 日
What do you get when you plot?
x = -720:720; plot(x, sind(x));
Ivan
Ivan 2012 年 4 月 2 日
plot looks like normal, but drops to -1 at -720:
>> sind(-720)
ans =
-1

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

採用された回答

Jan
Jan 2012 年 4 月 2 日
I asked Google for "Matlab bug sind" and found:
My conclusion: Ask MathWorks for a bugfix of your version. It is easy to insert a workaround as M-file in your toolbox folder:
function Y = sind(X)
Y = sin(X * 0.017453292519943295769236954843959);

その他の回答 (2 件)

Jan
Jan 2012 年 4 月 1 日
Does
which sind -all
reveal any unexpected details?
  2 件のコメント
Ivan
Ivan 2012 年 4 月 2 日
no. i think this is normal:
>> sind(30)
ans =
-0.8660
>> which sind -all
built-in (C:\MATLAB\toolbox\matlab\elfun\@double\sind) % double method
built-in (C:\MATLAB\toolbox\matlab\elfun\@single\sind) % single method
C:\MATLAB\toolbox\distcomp\parallel\@codistributed\sind.m % codistributed method
Ivan
Ivan 2012 年 4 月 2 日
The two contiguous commands give:
>> sind(30)
ans =
0.500000000000000
>> sind(30)
ans =
-0.866025403784439

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


Ivan
Ivan 2012 年 4 月 2 日
Thank you, Jan. Yes, i'm now using sin with argument in radians and that's ok. But this issue made me suspicious about all my results ever got with MatLab... Its very sad (
  1 件のコメント
Jan
Jan 2012 年 4 月 2 日
I agree that such bugs reduce the confidence. Therefore it would be great great great, if MathWorks offers a similar service as most other programs: Automatic download of patchs and bugfixes. Even a dynamically created list of known bugs would be helpful, while the bugs list at http://www.mathworks.com/support/bugreports/ is still too hidden for standard users. In addition it is weak: I do not find a report when I'm searching for "sind" on "all releases". Is it possible that this bug has not been reported?
It seems like this bug is either not reproducible or there is no or a not sufficiently powerful unittest for the elementary functions.
Please contact the technical support. The more votes they get the better for the users and the company.

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

Community Treasure Hunt

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

Start Hunting!

Translated by