Path: news.mathworks.com!not-for-mail
From: "Phil Goddard" <philgoddardNOSPAM@telus.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: 2D Array to Index a 3D Array?
Date: Fri, 21 Nov 2008 22:53:02 +0000 (UTC)
Organization: Goddard Consulting
Lines: 9
Message-ID: <gg7e4e$kue$1@fred.mathworks.com>
References: <718c2ac0-bc91-4be9-8fc5-5a4fbd364596@s20g2000yqh.googlegroups.com>
Reply-To: "Phil Goddard" <philgoddardNOSPAM@telus.net>
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 1227307982 21454 172.30.248.37 (21 Nov 2008 22:53:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 21 Nov 2008 22:53:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 26433
Xref: news.mathworks.com comp.soft-sys.matlab:502433



Another approach:

D = M(reshape(1:numel(J),size(J))+numel(J)*(J-1));

It's pretty hard to determine the most efficient approach without having a better idea of the true sizes of the matrices that you might be using.

Phil.