MATLAB: How can i manipulate a matrix with this characteristics

matrixmatrix manipulation

Hi, i have a matrix wtih repeated elements like:
[1 4 1 4 2 3 3 5 5 6 6 5]
i want break that matrix. And then in each other matrix, running in a cycle, have only the index referent to each number (1, 2, 3, …), something like:
1 2 3 4 5 6
[1 4] [2 3] [2 3 [1 4] [3 5 [5 6
3 5] 5 6 6 5]
6 5]
I tried creating a 3 dimension matrix (i,j,k) and each 3rd dimension having above matrix. That hypothesis gives me the repeated solutions inside. I tried to get them out but I might not be able to.
I hope someone can help me out.
PS: Some question that may have, just do it pls.
Regards, Vitor Ribeiro.

Best Answer

You can use cells for this. I do not see the pattern you have for [1 4 1 4 2 3 3 5 5 6 6 5] to the broken up matrix. but to set the broken up matrix with index references, cells should work.
MATRIX{1} = [1 4];
MATRIX{2} = [2 3];
MATRIX{3} = [2 3;3 5];
etc.
Which should be simple enough to accomplish in a for loop with whatever initial matrix breakup pattern is.