given the data matrix and indeces arrays for rows and columns
data=reshape(1:9,3,3)
row_index=[1,2,3];
column_index=[1,2,2];
I can get result=[1,5,6] by
for i =1:length(row_index)
result(i)=data(row_index(i),column_index(i));
end
How to vectorize the loop?