MATLAB: 3D matrix of cells

3d matrixcells

Let's say you have a 2D grid with 9 points/nodes, each node is represented by a vector with 9 elements. I want to represent this grid as a matrix, where each element in the matrix is i vector of length 9. What is the best way to do this in Matlab? I've looked in to the cell type, but cannot for the life of me figure out how the indexing works and how to perform arithmetic with cells

Best Answer

The indexing can be a bit confusing, particularly around identifying the cell, versus the contents of the cell. Here is an example that may help.
c = cell(3,3);
for i = 1:3
for j = 1:3
c{i,j} = rand(9,1);
end
end
% The 4th element of the (3,2) position of your 2D grid.
c{3,2}(4)
Related Question