Path: news.mathworks.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!feeder.erje.net!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Approximation problem???
Date: Fri, 20 Nov 2009 11:01:47 -0600
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <he6i29$sgv$1@news.eternal-september.org>
References: <he6gta$pll$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX1+POViyKHX/1Abmi4QHxvk4U29DDpP/88M0DNOk2zEuyOrZL86qrNjhIhnscJpk6f+R6XcdcyVJzdq/qS6I4FuXDau7xIrTFzd4nNSefjwGHYpVHpe0xw6deY7wD1fZ11xSnm6d1aUxPQ==
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Fri, 20 Nov 2009 17:02:02 +0000 (UTC)
In-Reply-To: <he6gta$pll$1@fred.mathworks.com>
X-Auth-Sender: U2FsdGVkX18FWyHEEo7PpgtWaFjkkDcxbVO2246mWQY=
Cancel-Lock: sha1:3qX2isvmpUO/+UMnjHmNdCTZ9GY=
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
Xref: news.mathworks.com comp.soft-sys.matlab:586749


Tales wrote:
...
> I am having a really weird problem that I cant find a reason. After a
> lot of calculation I was getting a wrong value for a variable, so I
> debbuged to find where was the problem, and I found a simple division
> mistake. A double h=0.0030 and another double hh=1/h .
> Of course hh is suposed to be 333.3333 but I am getting hh=333.8898
> Here is the piece of code:
> 
>                 h=str2double(cell2mat(raw(nameLinNum,densColumn)));
>                 hh=1/h;
> 
> Does anyone hava an idea on how to fix it???
...

Undoutedly h _isn't_ 0.00300000... but closer to 0.002995...

Try

disp(h-0.0030)

during a debugging session and see what is returned.

Why that is isn't determinable from the data provided but delving into 
where the underlying data come from and how they're processed will 
surely uncover same.

--