Creating a 2D grid with evenly spaced points

239 views (last 30 days)
I want to create a grid of evenly spaced points where the ponts are to be defined by a function (so not manually inputting all the x and y coordinates for each point). The grid is to look something like the attached image. I would like to make all the points equally spaced from one another (e.g. all the points are 2e-3 m away from each other).
there is to be around 1000 points so doing it manually is not an option - thank you

Accepted Answer

KSSV
KSSV on 29 Jun 2022
Read about meshgrid
x = linspace(0,1,10) ;
y = linspace(0,1,10) ;
[X,Y] = meshgrid(x,y) ;
plot(X,Y,'.r')
  3 Comments
aman verma
aman verma on 29 Jun 2022
I have a follow-up question. Is there a way to store the co-ordinates of each point in one single matrix. Taking the example you have given…
Matrix P = [0 0, 0 0.1, 0 0.2 … 1 1]
KSSV
KSSV on 29 Jun 2022
x = linspace(0,1,10) ;
y = linspace(0,1,10) ;
[X,Y] = meshgrid(x,y) ;
P = [X(:) Y(:)] ;

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!