# Discretise a domain into a grid of uniform volume size

2 visualizaciones (últimos 30 días)
daniel adams el 9 de Nov. de 2021
Editada: Sargondjani el 10 de Nov. de 2021
Given a domain say in how do I split/discretise the domain into a grid of uniform volume/ fixed number of grid points?
For example given how can I discretise this domain into a grid points? For some given . The linspace function has not been helpful for me.
##### 0 comentariosMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Sargondjani el 9 de Nov. de 2021
x1 = linspace(0,1,M);
x2 = linspace(0,1,M);
[X1,X2] = ndgrid(x1,x2);
##### 2 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Sargondjani el 10 de Nov. de 2021
Editada: Sargondjani el 10 de Nov. de 2021
Ok, so with linspace and ndgrid you get rectangles with equal area. So you only need to find the middle points of each segment? This would be the mean in each dimension.
dx1 = x1(2) - x1(1);%linspace results in equal distances between gridpoints
x1_mid = x1(1:end-1)+dx1;
And the same for x2. You now have a vector x1_mid and x2_mid which are the midpoints of the rectangular areas.

Iniciar sesión para comentar.

### Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by