MATLAB: Cell array or multidimensional array

cell arraysmatrix array

Which of the two is more MATLAB-friendly?
  1. Cell Array, or
  2. Multidimensional Array
If cell arrays are better than multidimensional arrays, how should I define the following array in cell array format:
A(128, 128, 17, 4, 25)
Suppose A is:
A(X, Y, Z, VARS, TIMES)
which means A contains the value of some variables VAR1, VAR2, …, VARN in a 3D space in different times.

Best Answer

Depends on what you are doing with the data downstream. If you are accessing array slices of A a lot, then the cell array approach might be more efficient because it would not involve data copying to access the slices (whereas accessing a slice of an nD array does involve a data copy each time you do it). But if you need to work with the data contiguously downstream then the nD array approach might be more efficient (rather than cat-ing the cell arrays together which would involve a data copy).