From: Luna Moon on
On Jun 23, 4:28 pm, "John D'Errico" <woodch...(a)rochester.rr.com>
wrote:
> Luna Moon <lunamoonm...(a)gmail.com> wrote in message <59fedfc4-9c35-400f-86ed-a7acbc9bc...(a)20g2000vbi.googlegroups.com>...
> > On Jun 23, 3:57 pm, "Roger Stafford"
> > <ellieandrogerxy...(a)mindspring.com.invalid> wrote:
> > > Luna Moon <lunamoonm...(a)gmail.com> wrote in message <57dc7fe3-2b8b-4ed7-870c-b73c87ae2...(a)a3g2000vbl.googlegroups.com>...
> > > > Here is the number I want to find, let's call it x,
>
> > > > here is the big vector, let me call it A,
>
> > > > I want to find the number x in A, in a fuzzy way.
>
> > > > Lets do an example: x=3, A=[0, 1, 2, 3, 4, 5],
> > > > then I want to identify the target location to be position 4.
>
> > > > Another example:
> > > > x=3, A=[0, 2, 4, 6, 8],
> > > > then I want to identify the target locations to be positions 2 and 3,
> > > > (i.e. the immediate location right before the placehold that x should
> > > > be in, and one immediately after...)
> > > > i.e. x=3 should have been in between 2 and 3, since we couldn't find
> > > > it in the vector
>
> > > > A is an ordered vector... not a set...
>
> > > > How to do that?
>
> > > > thanks
>
> > >  [ignore,bin] = histc(x,A);
>
> > > Roger Stafford- Hide quoted text -
>
> > > - Show quoted text -
>
> > Great idea but ...
>
> > Slightly off... I have to use one more "if" to fix it...
>
> > >> x=3, A=[0, 1, 2, 3, 4, 5],  [ignore,bin] = histc(x,A)
>
> > x =
>
> >      3
>
> > A =
>
> >      0     1     2     3     4     5
>
> > ignore =
>
> >      0     0     0     1     0     0
>
> > bin =
>
> >      4
>
> > >> x=3, A=[0, 1, 2, 4, 5],  [ignore,bin] = histc(x,A)
>
> > x =
>
> >      3
>
> > A =
>
> >      0     1     2     4     5
>
> > ignore =
>
> >      0     0     1     0     0
>
> > bin =
>
> >      3
>
> So, pray tell, how is that NOT what you asked for?
>
> bin is the number of the bin that x falls in. EXACTLY
> so.
>
> If you want to know the lower end point of that bin,
> then what does A(bin) give you?
>
> John- Hide quoted text -
>
> - Show quoted text -

when x is not in A, need two numbers (one before and one after)
returned...

it's no problem - i just have to add one more "if" statement to handle
that