Creating a 2D grid with evenly spaced points

93 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by