How can i manipulate a matrix with this characteristics?
2 views (last 30 days)
Show older comments
Vitor Ribeiro
on 9 Apr 2014
Commented: Vitor Ribeiro
on 10 Apr 2014
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.
0 Comments
Accepted Answer
Joseph Cheng
on 9 Apr 2014
Edited: Joseph Cheng
on 9 Apr 2014
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.
More Answers (1)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!