Skip to content

mat2cell

Split a matrix into a cell array of sub-matrices.

c = mat2cell(x, m, n, ...)

Splits matrix x into a cell array of blocks, where the row-block sizes are given by m, the column-block sizes by n, etc. Each m/n argument is a vector summing to the corresponding dimension of x.

mat2cell(magic(4), [2 2], [2 2]) % 2×2 cell of 2×2 blocks
  • cell2mat — Convert a cell array to a matrix.
  • num2cell — Convert a numeric array to a cell array.