You are accessing this site in a read-only mode. For full access to all member benefits, including message posting, please login or register. Registration is completely free, simple, and takes only a few seconds.
The message you are replying to and its parents are listed in the reverse order with the most recent posts first. This might not be the whole discussion thread. To read all the messages in this thread please click here.
Re: accessing multiple elements of matrix
Walter Roberson
16 Jul 2008 22:46
>x = [1 4 2] >y = [8 2 4]
>what I'd like to do is recover the elements >A(1,8) >A(4,2) >A(2,4)
A(sub2ind(size(A),x,y))
Signature
"Product of a myriad various minds and contending tongues, compact of obscure and minute association, a language has its own abundant and often recondite laws, in the habitual and summary recognition of which scholarship consists." -- Walter Pater
Alistair Templeton
16 Jul 2008 22:29
So I have a matrix A. Elsewhere in my code I generate a vector x and vector y, for example
x = [1 4 2] y = [8 2 4]
what I'd like to do is recover the elements A(1,8) A(4,2) A(2,4)
Is there a cleaner way to do this than something along the lines of: