Creating a 2D grid with evenly spaced points

95 Ansichten (letzte 30 Tage)
aman verma
aman verma am 29 Jun. 2022
Kommentiert: KSSV am 29 Jun. 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

Akzeptierte Antwort

KSSV
KSSV am 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 Kommentare
aman verma
aman verma am 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 am 29 Jun. 2022
x = linspace(0,1,10) ;
y = linspace(0,1,10) ;
[X,Y] = meshgrid(x,y) ;
P = [X(:) Y(:)] ;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by