MATLAB: Concatenate two cells of different dimention into a single array

arraycell arraysmatrix manipulation

I have three cells
so for example
Cell1 is 1x3 that is {1;1;1}
Cell2 is 3x2 that is {2,2;3,3;4,4}
Cell3 is 1x2 that is {1;1}
I want to concatenate all these cells into a single array so that i can see the results as
1 2 2 1
1 3 3 1
1 4 4

Best Answer

This works:
Cell1 = {1;1;1};
Cell2 = {2,2;3,3;4,4};
Cell3 = {1;1};
Cell3{3} = []; % Add Empty Element To End Of ‘Cell3’
Result = cat(2, Cell1, Cell2, Cell3)
Result =
[1.0000e+000] [2.0000e+000] [2.0000e+000] [1.0000e+000]
[1.0000e+000] [3.0000e+000] [3.0000e+000] [1.0000e+000]
[1.0000e+000] [4.0000e+000] [4.0000e+000] []