Skip to content

num2cell

Convert a numeric array to a cell array.

c = num2cell(A)
c = num2cell(A, dims)

Wraps each element of A in its own cell. With dims, groups elements together along the specified dimensions before wrapping.

num2cell([1 2; 3 4]) % {1, 2; 3, 4}
num2cell([1 2; 3 4], 1) % {[1; 3], [2; 4]} each col in one cell
  • cell2mat — Convert a cell array to a matrix.
  • mat2cell — Split a matrix into a cell array of sub-matrices.
  • cell — Information about formatting, location, or contents of a cell.