MATLAB: Why this logical expression is wrong accuracy problemfloating pointlogical?MATLAB Hi, why this statment is wrong, >> sind(30)==0.5 ans = 0 Best Answer because of the accuracy problem of a floating-point system>> format longE>> sind(30)ans = 4.999999999999999e-01Never, ever compare two floating-point numbers with == operand!See also:https://en.wikipedia.org/wiki/Floating-point_arithmetic#Machine_precision_and_backward_error_analysis Related SolutionsMATLAB: Help to understand a strange behaviour I asked Google for "Matlab bug sind" and found:See: Answers: bug-in-matlab-2010b-trig-functions.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); MATLAB: Drawellipse not working, can’t reproduce example which -all drawellipseLooks like you're shadowing this. Related QuestionConversion to single is out of rangeHow to change the number display from scientific notation to the full number in digitsUnable to save figures from figure window in matlab R2016bDoes 1 – 2/3 – 1/3 not equal zero
Best Answer