Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: ismember - getting wrong result
Date: Mon, 16 Mar 2009 12:41:13 +0000 (UTC)
Organization: Erasmus MC
Lines: 28
Message-ID: <gplhd9$fkq$1@fred.mathworks.com>
References: <gpb180$5uv$1@fred.mathworks.com> <gpb1n2$851$1@fred.mathworks.com> <gplfbn$3sp$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1237207273 16026 172.30.248.38 (16 Mar 2009 12:41:13 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 16 Mar 2009 12:41:13 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:525188


"Pete " <pete.dot.bankhead@btinternet.dot.com> wrote in message <gplfbn$3sp$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <gpb1n2$851$1@fred.mathworks.com>...
> .....
> > % also, peruse     
> > 
> > http://matlabwiki.mathworks.com/MATLAB_FAQ#Why_is_0.3-0.2-0.1_not_equal_to_zero_.28or_similar.29.3F
> > 
> > us
> 
> I found that link interesting.  I guess the colon operator is more complicated than I had realised.  Despite being aware of floating point considerations, I had found the behaviour of ismember (at least in 2008a) a bit odd at times, e.g.
> 
> ismember(0:.1:.5, 0:.1:.5)
> ans =
>      1     1     1     1     1     1
> >> ismember(0:.1:.5, 0:.1:.6)
> ans =
>      1     1     1     1     0     1
> >> ismember(0:.1:.5, 0:.1:.7)
> ans =
>      1     1     1     0     0     0

(again) it is not ismember, it is the colon operator behaving not as you (sic!) expect

a = [0:.1:.5]
b = [0:.1:.6]
[a .6] == b

Jos