Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!wns13feed!worldnet.att.net!64.192.187.27!news.glorb.com!news.aset.psu.edu!support1.mathforum.org!not-for-mail
From: crammer008 <luochao2000@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: What happened to so simple Matlab code?
Date: Wed, 21 Nov 2007 04:11:12 EST
Organization: The Math Forum
Lines: 13
Message-ID: <8220611.1195636303283.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: nitrogen.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1195636303 708 144.118.30.135 (21 Nov 2007 09:11:43 GMT)
X-Complaints-To: news@support1.mathforum.org
NNTP-Posting-Date: Wed, 21 Nov 2007 09:11:43 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:438640



Dear all, I have the following code and the corresponding results:
+++++++++++++++++++++++++++++++
>> aa = 0.005:0.01:0.025
aa =
    0.0050    0.0150    0.0250
>> daa = diff(aa)
daa =
    0.0100    0.0100
>> daa(1)-daa(2)
ans =
  1.7347e-018
++++++++++++++++++++++++++++++++++
Obviously, we should have daa(1)-daa(2) = 0. Who can tell me why Matlab can not give the correct result? Thanks!