Path: news.mathworks.com!not-for-mail
From: "jay vaughan" <jvaughan5.nospam@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: combine data?
Date: Wed, 16 Jul 2008 08:00:20 +0000 (UTC)
Organization: harvard
Lines: 20
Message-ID: <g5k9qk$kc5$1@fred.mathworks.com>
Reply-To: "jay vaughan" <jvaughan5.nospam@gmail.com>
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 1216195220 20869 172.30.248.35 (16 Jul 2008 08:00:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 16 Jul 2008 08:00:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1215048
Xref: news.mathworks.com comp.soft-sys.matlab:479686



Hi,

I am trying to find a way to combine data without using a 
loop. My data are similar to the following.

width  = [1 4 4 5 6 10 10 10 16];
weight = [1 1 2 1 1 4  2  2  1];

I would like to find a way to combine all entries where the 
width was the same, finding the total weight, like below.

combined_width  = [1 4 5 6 10 16];
combined_weight = [1 3 1 1 8  1];

I have to do this a million times or so and was hoping to 
do it efficiently. Any ideas on how to vectorize something 
like this?

Thanks,
J