Main Content
Preallocate Memory for Cell Array
Cell arrays do not require completely contiguous memory. However,
each cell requires contiguous memory, as does the cell array header
that MATLAB® creates to describe the array. For very large arrays,
incrementally increasing the number of cells or the number of elements
in a cell results in Out
of
Memory
errors.
Initialize a cell array by calling the cell
function, or by assigning to
the last element. For example, if C
does not already exist, these
statements are equivalent:
C = cell(25,50); C{25,50} = [];
MATLAB creates the header for a 25-by-50 cell array. However, MATLAB does not allocate any memory for the contents of each cell.