MATLAB: 3D-matrix

3d matrix

Can an 3D matrix store the coordinates (x,y,z) for each value in the matrix. Something like,
M_coord = [ {1,1,1}, {1,2,1}, {1,3,1}; {2,1,1}, {2,2,1}, {2,3,1}; {3,1,1}, {3,2,1}, {3,3,1} ];

Best Answer

A "matrix" is 2D. In consequence a "3D matrix" cannot store anything.
As long, as you do not specify exactly, what you want, it is impossible to give a valuable answer. But of course I can guess, that you want a CELL matrix:
M_coord = {[1,1,1], [1,2,1], [1,3,1]; ...
[2,1,1], [2,2,1], [2,3,1]; ...
[3,1,1], [3,2,1], [3,3,1]}
Or perhaps a 3D array:
M_coord = cat(3, [1,1,1; 2,1,1; 3,1,1], ...
[1,2,1; 2,2,1; 3,2,1], ...
[1,3,1; 2,3,1; 3,3,1]);