Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: averaging
Date: Wed, 23 Sep 2009 07:44:05 +0000 (UTC)
Organization: Michigan Technological University
Lines: 8
Message-ID: <h9cjk5$hcp$1@fred.mathworks.com>
References: <h9be7r$gh5$1@fred.mathworks.com> <h9brsm$r8s$1@fred.mathworks.com> <h9cegv$lip$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1253691845 17817 172.30.248.35 (23 Sep 2009 07:44:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Sep 2009 07:44:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 378863
Xref: news.mathworks.com comp.soft-sys.matlab:572264


> but I do not know that id1=round(23). The matrix A was used just as example. My matrix A is HUGE. What I need is to sort by col 1 and then average col2 according to col1. Any suggestions?

Does this work?

[dummy, dummy, i1] = unique(A(:,1));
avg = accumarray(i1, A(:,2), [], @mean);

--