I have a 2D array and I want to create a 1D by MATLAB, satisfying the requirement that each element of the 1D output was created by the value of a given index into the 2D array.
You are looking for sub2ind:
A=[2 4 6; 1 9 7; 3 4 5] X=[1;2;3]; Y=[1;2;3]; B = A(sub2ind(size(A),X,Y)) B = 2 9 5