Creating a 2D grid with evenly spaced points

91 vues (au cours des 30 derniers jours)
aman verma
aman verma le 29 Juin 2022
Commenté : KSSV le 29 Juin 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by