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:25:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <gpb2fi$t9e$1@fred.mathworks.com>
References: <gpb180$5uv$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 1236864306 29998 172.30.248.35 (12 Mar 2009 13:25:06 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 12 Mar 2009 13:25:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1747939
Xref: news.mathworks.com comp.soft-sys.matlab:524315


"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in message <gpb180$5uv$1@fred.mathworks.com>...
> Hi,
> 
> I have a matrix as follows,
> 
> a = 0:0.1:1;
> 
> when i tried to find whether 0.300 is present in the matrix 'a', using following procedure, 
> >> [tf, loc]=ismember(0.3,a)
> 
> i got the following result:
> tf =
>      0
> loc =
>      0
> But it suppose to give me, tf = 1 and loc =4.
> 
> Can anyone tell me, what is the problem and how to overcome it..
> Thanks !
> Ashwini
>  

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

ans =

     0     0     0     1     0     0     0     0     0     0     0