I have a 32 x 6 matrix consisting of repeats of 1-16 in each column in a specific order, e.g., :
X = [6 1 1 8 16 1 2 16 6 6 9 8 7 9 10 13 1 16 15 5 3 6 3 11 9 3 13 1 7 12 10 11 8 7 5 7 etc etc];
So given this set up, each instance of 1 – 16 will appear 12 times, twice in each column. What I need to do is create another matrix of the same size, indexing for each number where those repeats are occurring. So for example, if a column looked like this:
1 3 3 2 1
it would return:
1 1 2 (the second time 3 is appearing) 1 2 (the second time 1 is appearing)
I was thinking about using some kind of count function for each number and then perhaps applying a multiplication to it? Would be fine if these had to be separate matrices for each of the 16 numbers if that makes it any simpler. Any suggestions?
Best Answer