MATLAB: How to cell array all data into a matrices

cell array to matrix

suppose i have a cell array
a={{1,2,3};12;{21,32,43}};
how to get all data in single matrix
b=[1,2,3,12,21,32,43]'

Best Answer

Use horzcat and cell2mat:
b = cell2mat(horzcat(a{:}))
produces:
b =
1 2 3 12 21 32 43
I didn’t initially see the transpose operator. To get it as a column vector, add the transpose:
b = cell2mat(horzcat(a{:}))'