Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!q33g2000hsh.googlegroups.com!not-for-mail
From: Ross <fed.rossi@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: can I avoid a loop here?
Date: Tue, 19 Feb 2008 09:51:41 -0800 (PST)
Organization: http://groups.google.com
Lines: 22
Message-ID: <e01a38fc-431a-415f-9162-8e7ad7a422c0@q33g2000hsh.googlegroups.com>
NNTP-Posting-Host: 165.124.164.96
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1203443502 2647 127.0.0.1 (19 Feb 2008 17:51:42 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 19 Feb 2008 17:51:42 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: q33g2000hsh.googlegroups.com; posting-host=165.124.164.96; 
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.4) 
Xref: news.mathworks.com comp.soft-sys.matlab:452445


Hi,
I face the following problem:

Let j and x be two vectors of same length.
I would like to apply function FUN to the subset of xs, where the
subset is defined by the index j.

--------------
Eg:

j = [1 2 2 2 3 3]'
x = [6 43 3 4 2 5]'

FUN is sum

the result wanted is [6 50 7]'
-----------------

Is there a way to avoid looping?

Thank you
Ross