"Iftikhar Ali" <iftikharali4u@yahoo.com> wrote in message
news:mvvm4j$qhi$1@newscl01ah.mathworks.com...
> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message
> <f9ie92$4j1$1@canopus.cc.umanitoba.ca>...
>> In article <f9idh9$8ng$1@fred.mathworks.com>,
>> Jan <phyzix_chica@yahoo.com> wrote:
*snip*
> I am facing a problem related to above topic, and needs help.
>
> I have two arrays and want to find the index of elements.
>
> xpts = [0 0.0004 0.0011 0.0018 0.0025 0.003];
> x = 0:0.0001:0.003;
>
> index1 = find(ismember(x, xpts));
>
> It returns
> index1 = [1 5 12 26 31]
>
> But there is also an entry '0.0018' which belongs to both x and xpts but
> it is not included in the answer.
Welcome to the world of floating point arithmetic. See question 1 in the
Mathematics section of the FAQ for an explanation of this behavior.
http://matlab.wikia.com/wiki/FAQ
If you're using a sufficiently recent version of MATLAB, take a look at the
ISMEMBERTOL function.
--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com