Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Embedded For Loop?
Date: Wed, 11 Mar 2009 03:10:21 +0000 (UTC)
Organization: Battelle Energy Alliance (INL)
Lines: 17
Message-ID: <gp7a2t$rdn$1@fred.mathworks.com>
References: <16409623.1236739893454.JavaMail.jakarta@nitrogen.mathforum.org> <7656081.1236740115020.JavaMail.jakarta@nitrogen.mathforum.org>
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 1236741021 28087 172.30.248.35 (11 Mar 2009 03:10:21 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 11 Mar 2009 03:10:21 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 688530
Xref: news.mathworks.com comp.soft-sys.matlab:523936

One approach:

x = [1 2 3 4 5];
y = [9 8 7 6 5];
[xx,yy] = meshgrid(x,y);
z = xx+yy

Another:

x = [1 2 3 4 5];
y = [9 8 7 6 5]' ; % Note the transpose
z = x(ones(1,5),:)+y(:,ones(1,5))




&wc82lhawalwmf`YY]Ywm[qY]eelg`gdw=w~]gQh`~Zw[nwY]_YdgYgZEgf