MATLAB: Cell to matrix conversion with a slight modification

cell arraysMATLAB

I have a 1×501 cell array(named C). Each element in the cell is a 4*4 matrix, which means I have 501 matrices of 4*4 dimensions. What I have to do is: for each matrix in the cell, all the elements in the particular matrix must be put in 1 row.
for example I have to convert
[1,2,3,4 [0,1,0,0
5,6,7,8 1,0,0,0 ……….so one upto 501 matrices
9,10,11,12 0,0,1,1
13,14,15,16] 0,0,0,1]
into
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
0,1,0,0,1,0,0,0,0,0,1,1,0,0,0,1
………….
……..
so on upto 501 rows. ]
Help if possible.

Best Answer

Assuming that you mean a 501x16 matrix, then:
m = reshape(cat(3, yourcellarray{:}), [], numel(yourcellarray)).'
This concatenate the 501 matrices into a 4x4x501 matirx array, reshape that into a 16x501 matrix where each column is a flattened matrix and then transpose into a 501x16 matrix.