Path: news.mathworks.com!not-for-mail
From: Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Give me a good example for accumarray()
Date: Mon, 06 Jul 2009 11:55:40 -0400
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <h2t6ps$1s$1@fred.mathworks.com>
References: <h2n5b9$lo7$1@fred.mathworks.com> <h2o770$668$1@fred.mathworks.com>
NNTP-Posting-Host: perkinsp.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1246895740 60 172.31.57.88 (6 Jul 2009 15:55:40 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 6 Jul 2009 15:55:40 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)
In-Reply-To: <h2o770$668$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:553137


Husam Aldahiyat wrote:

> For example for first column value (1) I will get
> 
> 1 1
> 1 2
> 1 3
> 
> and for first column value (3)
> 
> 3 7
> 3 8

ACCUMARRAY may or may not be able to help here.  The SUBS input determines how values in the VALS input are batched up when passed to your FUN, but FUN has no access to the SUBS values themselves.  Thus, AUUMARRAY can easily return [1; 2; 3], but you will need to do something additional to get [1 1; 1 2; 1 3].