I would like to plot a square in a 2D cartesian coordinate system with its corners at (±1,±1)
. I would like to further divide it to 400 smaller and equal squares each with an edge length of 0.1
.
How can I do this in MATLAB?
I would like to plot a square in a 2D cartesian coordinate system with its corners at (±1,±1)
. I would like to further divide it to 400 smaller and equal squares each with an edge length of 0.1
.
How can I do this in MATLAB?
You can generate the grid with the right number of vertical and horizontal lines:
See the rectangle function. For example, try
This looks like a problem I had to solve. What I do below is get the coordinates of all the points with meshgrid. Then I get the distance from everey point to every other point with pdist, when the distance is 1 its is a connection we want to draw. Then we plot all those lines.