3D matrix of cells?

1 view (last 30 days)
sigurd
sigurd on 17 Sep 2013
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

Accepted Answer

the cyclist
the cyclist on 17 Sep 2013
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)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!