Discretise a domain into a grid of uniform volume size
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Given a domain say in
how do I split/discretise the domain into a grid of uniform volume/ fixed number of grid points?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/795564/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/795569/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/795574/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/795579/image.png)
0 Kommentare
Antworten (1)
Sargondjani
am 9 Nov. 2021
Why is linspace not helpful?
x1 = linspace(0,1,M);
x2 = linspace(0,1,M);
[X1,X2] = ndgrid(x1,x2);
2 Kommentare
Sargondjani
am 10 Nov. 2021
Bearbeitet: Sargondjani
am 10 Nov. 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.
Siehe auch
Kategorien
Mehr zu Triangulation Representation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!