Creating a 2D grid with evenly spaced points

223 visualizaciones (últimos 30 días)
aman verma
aman verma el 29 de Jun. de 2022
Comentada: KSSV el 29 de Jun. de 2022
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

Respuesta aceptada

KSSV
KSSV el 29 de Jun. de 2022
Read about meshgrid
x = linspace(0,1,10) ;
y = linspace(0,1,10) ;
[X,Y] = meshgrid(x,y) ;
plot(X,Y,'.r')
  3 comentarios
aman verma
aman verma el 29 de Jun. de 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 el 29 de Jun. de 2022
x = linspace(0,1,10) ;
y = linspace(0,1,10) ;
[X,Y] = meshgrid(x,y) ;
P = [X(:) Y(:)] ;

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by