Basically, numeric matrix data types in MATLAB are allocated non-fragmented memory. As you move along columns in a matrix, you traverse adjacent memory locations.
The different elements of a cell array, however, can hold matrices or other objects of different data types (strings, structs, other cell arrays) and sizes. Because each of these objects may be non-scalar and can be of a different size/type, they cannot necessarily neighbor each other in memory.
When you pre-allocate a cell by doing
it is like you are creating N separate MATLAB variables except that they do not have distinct names (x,y,z, etc...) and they do not hold any data yet. If you place matrices in each cell location C{i}, then the matrix content of each C{i} individually will occupy contiguous memory, as usual. However, the data corresponding to different C{i} are like different variables and needn't neighbor each other.
Best Answer