Documentation Center

  • Trial Software
  • Product Updates


Convert cell array to numeric array


A= cell2mat(C)


A= cell2mat(C) converts cell array C with contents of the same data type into a single array, A.

Input Arguments


Cell array, where each cell contains the same type of data. The cell2mat function accepts numeric or character data within cells of C, but not structs, objects, or nested cells.

The contents of C must support concatenation into a hyperrectangle. Otherwise, the results are undefined. For example, the contents of cells in the same column must have the same number of columns, although they need not have the same number of rows.

Output Arguments


Array of the same type as the contents of the cells of C. The number of dimensions of A matches the highest number of dimensions of arrays within C.


Combine matrices in the four cells of cell array c into matrix m.

c = {[1],    [2, 3, 4];
     [5; 9], [6, 7, 8; 10, 11, 12]};

m = cell2mat(c)

m is a 3-by-4 matrix:

m =
     1     2     3     4
     5     6     7     8
     9    10    11    12

See Also


Was this topic helpful?