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]); Related SolutionsMATLAB: How to write MATRIX I am not sure to have understood your question but you should try:M =1-eye(10);By the way: avoid loops in Matlab ;-) Hope it helps, MATLAB: How many ways to arrange numbers from 1-3 [A,P,Z] = ndgrid(1:3); [Z(:), P(:), A(:)] Related QuestionPermutation of numbers when repetition of digits is allowed.How to multiply a vector 3 times to get a 3 dimentional matrixHow to convert a given data in 3D formatMatrix and element change and input helpNeed help using mink and maxk
Best Answer