MATLAB: Coordinates of a square array with a loop

distance between pointsloopssquare array

I have a 7×7 array of points, all equally spaced, 1 unit apart, hence the coordinate matrix looks something like:
d=[0,0; 0,1; 0,2; 0,3...; 1,0; 1,1; ...1,6; etc]
how to I generate this matrix for any N number of points in the array? (it's always going to be a square of m x m)

Best Answer

I assume you're looking for meshgrid, though your question isn't clear.
[xx yy] = meshgrid(0:6);
[xx(:) yy(:)]