From: "Joao Ejarque" <>
Newsgroups: comp.soft-sys.matlab
Subject: Extracting a matrix from a 3D array using an index matrix
Date: Thu, 9 Jun 2011 11:05:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 8
Message-ID: <isq9d1$2pd$>
Reply-To: "Joao Ejarque" <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1307617505 2861 (9 Jun 2011 11:05:05 GMT)
NNTP-Posting-Date: Thu, 9 Jun 2011 11:05:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2909199
Xref: comp.soft-sys.matlab:731013

I have two 3D arrays, C andY, both of size (n1,n2,n3).
I create [Vy Iy]=max(Y,[],3), where Iy is a matrix of indices of size (n1,n2).
I want to extract the two dimensional  D=C(Iy), size (n1,n2), where the elements of this new matrix D are the elemets of C that have the same position along dimension 3 as the elements of Vy.
What is te simplest way to do it?