Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: adding a vector to each col of a previous vector
Date: Wed, 4 Nov 2009 17:19:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <hcsd27$15e$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 1257355143 1198 172.30.248.35 (4 Nov 2009 17:19:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 4 Nov 2009 17:19:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1611872
Xref: news.mathworks.com comp.soft-sys.matlab:582452


I use too many loops all the time and I want to become more familiar with vector notation and matrix manipulation.
So I would like to know the following.
Without using a loop what is the most elegant (and efficient) way to add a new vector to each col of another vector.
For example:
a = [1 5 20 35 100]
b = 0:4;

c = [1 5 20 35 100
       2 6 21 36 101
       3 7 22 37 102
       4 8 23 38 103
       5 9 24 39 104]

This is probably pretty easy. Help me out if you can.