MATLAB: How to get the vertex points of all grid points within a cube

3d plotsscatterplot

If I have a NxN cube, and wanted to plot a point at each integer x,y,z position included in the cube, how could I iterate through and store all the points to x,y,z point arrays?

Best Answer

It was a lot easier than I first realized, here was my solution to the problem after simply writing it out on paper and seeing a pattern. N=5
d1 = 0;
d2 = 0;
d3 = 0;
for k = 0:5
d1 = k;
for j = 0:5
d2 = j;
for i = 0:5
d3 = i;
scatter3(d1,d2,d3,0.5,'r'); hold on;
end
end
end