Path: news.mathworks.com!not-for-mail
From: "Phil Goddard" <philgoddardNOSPAM@telus.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Voxel loop optimisation
Date: Thu, 27 Mar 2008 06:05:10 +0000 (UTC)
Organization: Goddard Consulting
Lines: 13
Message-ID: <fsfdem$ait$1@fred.mathworks.com>
References: <fsevre$cg7$1@fred.mathworks.com>
Reply-To: "Phil Goddard" <philgoddardNOSPAM@telus.net>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1206597910 10845 172.30.248.38 (27 Mar 2008 06:05:10 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 27 Mar 2008 06:05:10 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 26433
Xref: news.mathworks.com comp.soft-sys.matlab:459401


You could use ARRAYFUN in conjunction with an appropriate 
function handle, i.e.

fh = @(idx,page) rc(idx,:,page)';
myIndexed2d = cell2mat(arrayfun(fh,idxs,1:length
(idxs),'UniformOutput',false))';

However, if you're looking for speed, then in newer 
versions of MATLAB (at least since since R2006a) the loop 
is likely to be faster for the purely numeric data that 
you're manipulating.

Phil.