Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: find vector r<=p (p: a given vector)
Date: Thu, 20 Nov 2008 21:48:01 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 10
Message-ID: <gg4luh$lv0$1@fred.mathworks.com>
References: <gf2ppf$q6l$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227217681 22496 172.30.248.37 (20 Nov 2008 21:48:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 20 Nov 2008 21:48:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:502157


% Data
p=round(9*rand(1,5))+1;

% Engine
c=arrayfun(@(k) 0:p(k), 1:length(p), 'UniformOutput', false);
[c{:}]=ndgrid(c{:});
R=reshape(cat(length(p)+1,c{:}),[],length(p));

% Bruno