Merge cell arrays with special algorithm
Show older comments
Hello,
I need to create a different output cell aray, when I have input cell array. I have at input:
in = { [1,1] = 100001
[2,1] = 100000
[3,1] = 100001
[4,1] = 100000
[1,2] = 8, 9, 10, 11, 12
[2,2] = 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
[3,2] = 28, 29, 30, 31, 32
[4,2] = 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72
}.
I need output cell at size (n,2), where n is the number of different values at first column - it means at this case, n = 2, beacuse we have '100001' and '100000'. When it would be e.g. '100000', '100001','100002', then n = 3, etc. At the second column at out, it should be a vectors from input(i,2) respectively fit to first column - I mean, all vectors from one number, should be concatenated to one big vector. So the output cell (in the discussed case) should be:
out ={ [1,1] = 100000
[2,1] = 100001
[1,2] = [8, 9, 10, 11, 12 ,28, 29, 30, 31, 32]
[2,2] = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72]
}.
So the first column is a "title" of the second column, which contains a all numeric value from properly columns from input.
I know, I have described it not so clear, but maybe, it can be understand :D Thanks for help in advance, and if You have question to me, ask! Thanks!
Answers (0)
Categories
Find more on Matrices and Arrays 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!