I have a matrix, for example
A = [ 1 2 3; 4 5 6; 7 8 9] ;
and a vector of size 1x3 which specifies which element in each row is the one I\
It's a bit ugly, but diag(A(1:3,[1 2 1])) will do the trick.
diag(A(1:3,[1 2 1]))