MATLAB Function Reference    

Convert cell array of matrices into single matrix



m = cell2mat(c) converts a multidimensional cell array, c, with contents of the same data type into a single matrix, m. The contents of c must be able to concatenate into a hyperrectangle. Moreover, for each pair of neighboring cells, the dimensions of the cell's contents must match, excluding the dimension in which the cells are neighbors.

The example shown below combines matrices in a 3-by-2 cell array into a single 60-by-50 matrix:


The dimensionality (or number of dimensions) of m will match the highest dimensionality contained in the cell array.

cell2mat is not supported for cell arrays containing cell arrays or objects.


Combine the matrices in four cells of cell array C into the single matrix, M:

See Also

mat2cell, num2cell

  cell cell2struct