Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: ismember - getting wrong result
Date: Thu, 12 Mar 2009 13:52:02 +0000 (UTC)
Organization: Erasmus MC
Lines: 22
Message-ID: <gpb422$6m3$1@fred.mathworks.com>
References: <gpb180$5uv$1@fred.mathworks.com> <gpb2fi$t9e$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 1236865922 6851 172.30.248.35 (12 Mar 2009 13:52:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 12 Mar 2009 13:52:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:524325


"Pj " <northern69@yahoo.com> wrote in message <gpb2fi$t9e$1@fred.mathworks.com>...
> "Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in message <gpb180$5uv$1@fred.mathworks.com>...
<SNIP ... FP problem with ismember

> Try:
> >> a=0:10;
> >> a=a/10;
> >> ismember(a, 0.3)
> 
> ans =
> 
>      0     0     0     1     0     0     0     0     0     0     0

Poor advise! Do not rely on this. It may work here, but fails elsewhere. 

a = 1:10 ; a = a/10 ;
ismember(a, 0.3)
ismember(a-0.1, 0.2)

One is better off understanding the limitations of computer systems in representing numbers.

Jos