Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Incoerences in MATLAB
Date: Thu, 11 Dec 2008 23:59:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <ghs9g7$gh1$1@fred.mathworks.com>
References: <ghs86t$528$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1229039943 16929 172.30.248.35 (11 Dec 2008 23:59:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 11 Dec 2008 23:59:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:506449


"Trouble Finders Costa" <valencadante@hotmail.com> wrote in message <ghs86t$528$1@fred.mathworks.com>...
> I have discovered some incoerences and troubles in some commands of MATLAB. These problems caused me headaches by the time I have faced them for the first time, because of the loss of several minutes in work until the perception of the problem.
> 
> One of this problems, an incoerence, is: try if [125000:125000:10/0.00001] and [125000:125000:1000000] are vectors of the same dimension when generated in MATLAB.
> 
> Another problem, a trouble, has to do with the question of numerical precision. Try the following commands:
> time = 0; time_increment = 0.01; n = (a number of your choice);
> for i = 1:n
>     time = time  + time_increment;
> end
> 
> You will notice that, for large values of "n", some decimal numbers will appear after the second one. This shouldn't happen. I have observed this problem for values of "time_increment" less than 0.1
> 
> Thank you for your attention.
> 
> Dante Valen?a.

  What you are calling an "incoerence" actually represents a failure on the part of many users to understand that Matlab uses a binary number system.  It has no way to express such values as 0.01 and 0.00001 exactly and must necessarily make very small round off errors in the above calculations.  This has been discussed ad infinitum in previous threads.  It is a common characteristic of any computing system that uses binary number fractions, just as a failure to be able to express 1/3 exactly is a shortcoming of decimal machines.

Roger Stafford