Prev: Structure & Loop
Next: options menu with nodisplay
From: Scott on 28 May 2010 15:28 Debugging a simple program and found that. Bottom1(l)+0.1<Bottom2(l) was evaluating as true when Bottom1(l) = -0.4 and Bottom2(l)=-0.3 when I was expecting false as the two halves of the expression should be equal was also able to get this from the debug line K>> -0.4+0.1<-0.3 ans = 1 K>> -0.3<-0.3 ans = 0 I'm guessing I'm formatting the expression incorrectly but can't figure out what I'm doing wrong. Thanks for any help
From: Walter Roberson on 28 May 2010 15:39 Scott wrote: > K>> -0.4+0.1<-0.3 > > ans = > > 1 floating point roundoff error. It's a reality of life, and inescapable in any finite representation. http://matlabwiki.mathworks.com/MATLAB_FAQ#Why_is_0.3-0.2-0.1_not_equal_to_zero_.28or_similar.29.3F
From: us on 28 May 2010 16:01 "Scott " <tweedlest(a)remove.this.aol.com> wrote in message <htp5gk$lmj$1(a)fred.mathworks.com>... > Debugging a simple program and found that. > > Bottom1(l)+0.1<Bottom2(l) > was evaluating as true when Bottom1(l) = -0.4 and Bottom2(l)=-0.3 > when I was expecting false as the two halves of the expression should be equal > > was also able to get this from the debug line > > K>> -0.4+0.1<-0.3 > > ans = > > 1 > > K>> -0.3<-0.3 > > ans = > > 0 > I'm guessing I'm formatting the expression incorrectly but can't figure out what I'm doing wrong. Thanks for any help a hint: - FP evergreen... http://matlabwiki.mathworks.com/MATLAB_FAQ#Why_is_0.3-0.2-0.1_not_equal_to_zero_.28or_similar.29.3F us
From: ImageAnalyst on 28 May 2010 16:04 You may also want to read about "eps" in the help.
|
Pages: 1 Prev: Structure & Loop Next: options menu with nodisplay |