Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: FAST algorithm to jenga matrix?
Date: Sun, 29 Mar 2009 10:48:01 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 8
Message-ID: <gqnjl1$us$1@fred.mathworks.com>
References: <gqmlmt$6tp$1@fred.mathworks.com> <gqn6u7$1s2$1@fred.mathworks.com> <gqnf8d$8kh$1@fred.mathworks.com> <gqniod$6ne$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
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 1238323681 988 172.30.248.35 (29 Mar 2009 10:48:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 29 Mar 2009 10:48:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:528438

For fun, two-liner solution:

[f NewVal]=ismember(1:max(nonzeros(A)),setdiff(1:max(nonzeros(A)),d));
A(A~=0)=NewVal(nonzeros(A));

Now how to get to one-liner solution (challenge proposed by Roger)?

Bruno