Skip to content
Prev 323086 / 398502 Next

Extracting elements from a matrix using a vector containing indices

On 07-05-2013, at 06:39, Mark Coletti <mcoletti at gmail.com> wrote:

            
It's not clear what you want.
The vector C contains row numbers or column numbers?
So you want to extract a single element from each column?
Your matrix is Mat and the vector is called vec

Mat[vec,]

should do it.

If this is not what you want you will have to be more specific.

Berend