MATLAB: Get specific elements from matrix

matrix manipulation

Hello,
From an arbitrary matrix I want to extract n elements when I have 2 arrays of lenth n, one containing the row indices and 1 containing the column indices of the desired elements.
For effeciency I would like to avoid a for loop. Is this possible?
Thanks!

Best Answer

YourMatrix( sub2ind( size(YourMatrix), Rows, Columns ) )