octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no way for simple matrix lookup ?


From: D. Goel
Subject: Re: no way for simple matrix lookup ?
Date: Wed, 16 Jun 2004 15:08:22 -0400
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux)

Etienne Grossmann <address@hidden> 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?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]