Path: news.mathworks.com!not-for-mail
From: "us " <us@neurol.unizh.ch>
Newsgroups: comp.soft-sys.matlab
Subject: Re: String Manipulation
Date: Mon, 30 Jul 2007 15:14:56 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 19
Message-ID: <f8kv9g$8md$1@fred.mathworks.com>
References: <f8kt2a$hsl$1@fred.mathworks.com>
Reply-To: "us " <us@neurol.unizh.ch>
NNTP-Posting-Host: webapp-00-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1185808496 8909 172.30.248.35 (30 Jul 2007 15:14:56 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 30 Jul 2007 15:14:56 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:421703


Alan Leung:
<SNIP combinatorial evergreen...

one of the many solutions

% some data
     tok='A':'C';
% the (versatile) engine
     n=numel(tok);
     x=cell(n,1);
     [x{1:n}]=ndgrid(tok);
     p=reshape(cat(n+1,x{:}),[],n);
     p=p(:,end:-1:1);
% the result
     tok
     p

us