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:
>
> >I was wondering if there is an easy way to locate a certain
> >value in an array and find the index of that value. I can
> >write a quick function to do it but I was just wondering if
> >Matlab has something built in.
>
> index = find(array==value,1);
>
> OR
>
> [tf, index] = ismember(value, array)
>
> >Incidentally, the array is monotonically increasing, if that
> >helps.
>
> You might want to read through the ismember.m source code .
> Look for ismembc2() there.
> --
> Programming is what happens while you're busy making other plans.
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.
> In article <f9idh9$8ng$1@fred.mathworks.com>,
> Jan <phyzix_chica@yahoo.com> wrote:
>
> >I was wondering if there is an easy way to locate a certain
> >value in an array and find the index of that value. I can
> >write a quick function to do it but I was just wondering if
> >Matlab has something built in.
>
> index = find(array==value,1);
>
> OR
>
> [tf, index] = ismember(value, array)
>
> >Incidentally, the array is monotonically increasing, if that
> >helps.
>
> You might want to read through the ismember.m source code .
> Look for ismembc2() there.
> --
> Programming is what happens while you're busy making other plans.
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.