Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Extracting a matrix from a 3D array using an index matrix
Date: Thu, 9 Jun 2011 19:33:04 +0000 (UTC)
Organization: Xoran Technologies
Lines: 13
Message-ID: <isr75g$39l$1@newscl01ah.mathworks.com>
References: <isq9d1$2pd$1@newscl01ah.mathworks.com> <isr5mk$ro2$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1307647984 3381 172.30.248.45 (9 Jun 2011 19:33:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 9 Jun 2011 19:33:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:731136

"Matt J" wrote in message <isr5mk$ro2$1@newscl01ah.mathworks.com>...
> Another option:
> 
> 
> idx=reshape(  (1:n1*n2).' + (Iy(:)-1)*n3  , n1,n2 );
> D=C(idx);


make that

p=n1*n2;
idx=reshape(  (1:p).' + (Iy(:)-1)*p  , n1,n2 );
D=C(idx);