Path: news.mathworks.com!not-for-mail
From: "Joao Ejarque" <jme@dreammodel.dk>
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$1@newscl01ah.mathworks.com>
Reply-To: "Joao Ejarque" <jme@dreammodel.dk>
NNTP-Posting-Host: www-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1307617505 2861 172.30.248.37 (9 Jun 2011 11:05:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 9 Jun 2011 11:05:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2909199
Xref: news.mathworks.com 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?

Thanks

Joao