Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: HOWTO: Accelerate processing algorithm
Date: Sun, 5 Jul 2009 14:25:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 15
Message-ID: <h2qd3u$md0$1@fred.mathworks.com>
References: <14646834.75779.1246802812202.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
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 1246803902 22944 172.30.248.35 (5 Jul 2009 14:25:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 5 Jul 2009 14:25:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:552888


Jose Antonio <juriguen@gmail.com> wrote in message <14646834.75779.1246802812202.JavaMail.jakarta@nitrogen.mathforum.org>...
> Ok, I think this makes it
> 
> S = accumarray(y(:)+1,v(:), [], @mean)

Jose,
 
I believe the above might be not the fastest, this could be even faster:

yp1 = y(:)+1;
S = accumarray(yp1,v(:))./accumarray(yp1,1);

accumarray likes to work with 'sum'. Just a though

Bruno