Path: news.mathworks.com!not-for-mail
From: "Ulrik Nash" <uwn@sam.sdu.dk>
Newsgroups: comp.soft-sys.matlab
Subject: Conditional summing
Date: Thu, 11 Mar 2010 14:36:22 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <hnav56$o8e$1@fred.mathworks.com>
Reply-To: "Ulrik Nash" <uwn@sam.sdu.dk>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1268318182 24846 172.30.248.37 (11 Mar 2010 14:36:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 11 Mar 2010 14:36:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2106050
Xref: news.mathworks.com comp.soft-sys.matlab:615945

Hi Everyone,

Suppose I have a column vector 

A = 
1 
2 
3 
4 
5

And also a matrix

B =

1 10
3 22
2 12
4 13

Now I wish to create a matrix C, which has A as its first column, and the sum of the second column in B for those values found in B's first column:

C = 
1 10
2 12
3 22
4 13
5 0

How would I do this?

Regards,

Ulrik.