From maintainers-request at octave dot org Wed Jun 16 14:11:36 2004 Subject: Re: no way for simple matrix lookup ? From: "D. Goel" To: maintainers at octave dot org Cc: help at octave dot org Date: Wed, 16 Jun 2004 15:08:22 -0400 Etienne Grossmann writes: > A = reshape (1:12, 3,4); > > b = [2 3 1 2 3]; > c = [4 1 2 3 4]; > > D = A(sub2ind (size (A),b, c)) > > D = diag (A(b,c)) # Don't do that > Many thanks to Etienne for the above solution, and to everyone else for similar solutions. Anyone have any ideas on the question below (which is the actual problem at hand) --> > # > # [3] More generally, the problem i am struggling with is: > # > # A is a nxmxl matrix. b and c are vectors. > # I am looking for a vector D, such that D(i,:)= A(b(i), :, c(i)). > # > # Any way to do that?