Can MATLAB handle multidimensional arrays?
Many MATLAB users commonly ask the question, “Can I use multidimensional arrays in MATLAB?” The answer is both yes and no. No, in that multidimensional arrays are not built into MATLAB. MATLAB’s internal data stucture is limited to a two-dimensional matrix. But you can create your own functions in the MATLAB language to handle multidimensional arrays. The following is an example that maps a three-dimensional matrix to a single vector. The indices are passed to a function as if it were a three-dimensional matrix. Then the indices are translated to a single vector with corresponding offsets. The exact implementation will be specific to what you want to accomplish. function position = index3(d,i,j,k) %INDEX3 POSITION = INDEX3(d,i,j,k) index a 3-D array % d is a vector that specifies the dimensions on the array position = (i+(j-1)*d(2)+(k-1)*d(2)*d(3)); The following is an example of how you might use this function. D = [9 9 9]; % D give the dimensions as 9x9x9 A = 1:(9*9*9); % A is where