I have a matrix containing group identifiers:
A = [ 1 ; 1 ; 2;2;2;3;3]
and I would like to enhance this by a running sequence by group to obtain a matrix like this:
B = [ 1,1 ; 1,2 ; 2,1;2,2;2,3;3,1;3,2]
B =
1 1
1 2
2 1
2 2
2 3
3 1
3 2
How can I do this without using the dreaded for-loop? Thank you!