Create indexes for other dimensions.
In dim 1, the index should change rapidly: [1,2,...,size(A,1)] and size(A,3) times:
idx1 = repmat((1:size(A,1))',size(A,3),1);
In dim 2, the index is given by Ind .
In dim 3, the index should change more slowly: [1,1,...,1] for size(A,1) times, and then [2,2,...,2] , etc. to size(A,3) .
idx3 = ones(size(A,1),1)*(1:size(A,3));
Access to individual values:
M_ = A(sub2ind(size(A),idx1(:),Ind(:),idx3(:)));
For comparison:
M(:) == M_