I have a matrix (not square one) with an elements that are repeating, for example:
Starting from second column, I need to shift up each column in order to align in rows elements with the same values. Empty elements of a new matrix should be replaced by the zeros. In result I should have:
Then the same pattern of a shift I should be able to apply to any other matrix with the same dimensions as the original one (but this time without such nicely repeating numbers as elements).
Could someone please help me solve this problem?
Sorry I was not very specific in my question.
I have two matrixes. One n x m, lets call it MAIN, with results that I have to process (with some more or less random numbers), and second n x m, lets call it AUXILIARY, that is an indication how the first has to be processed (matrix from my example, with repeating numbers).
I need to analysie the auxiliary matrix in a way I've described in my question and find about how many positions I have to shift each column. In my example I need to shift 1st column by 0 positions, 2nd by 1 position up etc.
Then I need to apply the same pattern to the main matrix. So 1st column of main matrix is unchanged, 2nd should be shifted by 1 position up etc.
I hope now it's more clear.
Thanks for your help.