Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!k79g2000hse.googlegroups.com!not-for-mail
From:  ralphs <ralph.schmidt@heller.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find nearest index
Date: Wed, 01 Aug 2007 01:07:27 -0700
Organization: http://groups.google.com
Lines: 16
Message-ID: <1185955647.361597.308330@k79g2000hse.googlegroups.com>
References: <f8mjkc$m3i$1@fred.mathworks.com>
NNTP-Posting-Host: 193.98.76.14
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1185955647 20585 127.0.0.1 (1 Aug 2007 08:07:27 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 1 Aug 2007 08:07:27 +0000 (UTC)
In-Reply-To: <f8mn26$nk1$1@fred.mathworks.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: k79g2000hse.googlegroups.com; posting-host=193.98.76.14;
Xref: news.mathworks.com comp.soft-sys.matlab:422008


On Jul 31, 9:06 am, "Sven " <sven.holco...@removethis.gmail.com>
wrote:
> To give some more context, I am running this on a set of numbers after making some bins using the hist function.
> The hist function returns the centres of each bin, and I would now like to loop over my original set of numbers and find out which bin it belongs in.
>
> Thanks,
> Sven.

Dear Sven,

you can use histc with two lhs arguments: [n, bins] = histc(x);
In bins you get an vector with the indices.

HTH.
Ralph