How to modify the mesh generated from meshgrid to create a rectangular void in the middle of the mesh
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi , I'm new to matlab and trying to create a void or remove the points within a rectangular area in the mesh grid. I have to use this meshgrid to generate structured mesh for FEA.
The mesh grid is ;
[x y] = meshgrid([0: 1: 15],[0: 0.5 :13])
The x & y coordinates for the four corner points of rectangular area ; p1= [5.6 3.8] ; p2= [9.4 3.8] ; p3 =[9.4 9.2] ; p4= [3.8 9.2]
How do I do this?If this is not possible, please provide advise how to select the points/element nodes witin the rectangular area. I appreciate if someone can provide some help on this.
Thanks
0 comentarios
Respuestas (2)
Epsilon
el 27 de Nov. de 2024
Editada: Epsilon
el 27 de Nov. de 2024
Hi Prasad,
To create a void set the values at the indices to 'NaN'.
[x, y] = meshgrid(0:1:15, 0:0.5:13);
voidIndices = (x >= 5.6 & x <= 9.4) & (y >= 3.8 & y <= 9.2);
% Remove points inside the rectangle by setting them to NaN
x(voidIndices) = NaN;
y(voidIndices) = NaN;
plot(x, y, 'b.');
To know more about 'NaN' refer to the link: https://www.mathworks.com/help/matlab/ref/nan.html?
3 comentarios
Walter Roberson
el 28 de Nov. de 2024
You cannot do this using delaunayTriangulation . delaunayTriangulation does not give the possibility of excluding an area. delaunayTriangulation() only accepts finite coordinates.
If you extract the non-nan values from x and y:
[x, y] = meshgrid(0:1:15, 0:0.5:13);
voidIndices = (x >= 5.6 & x <= 9.4) & (y >= 3.8 & y <= 9.2);
% Remove points inside the rectangle by setting them to NaN
x(voidIndices) = NaN;
y(voidIndices) = NaN;
XY = rmmissing([x(:), y(:)]);
DT = delaunayTriangulation(XY(:,1), XY(:,2))
triplot(DT)
Notice that you get triangles crossing the void. The large space shown there is not void -- it is a pair of large triangles occupying the area enclosed.
Walter Roberson
el 27 de Nov. de 2024
You might be better off taking a different approach. You might be better off decomposing a geometry
If you follow the steps from the examples at https://www.mathworks.com/help/pde/ug/decsg.html you should be able to build a decomposed mesh. You might then fegeometry the result.
2 comentarios
Walter Roberson
el 28 de Nov. de 2024
You can follow the steps given at https://www.mathworks.com/help/pde/ug/create-geometry-at-the-command-line.html to create two rectangles, and then set the function to be R1-R2 and then [dl,bt] = decsg(gd,sf,ns); to get the decomposed geometry in a form suitable for use with the PDE toolbox.
You can construct a fegeometry from the description matrix; https://www.mathworks.com/help/pde/ug/fegeometry.html#mw_e77501a3-de38-4ca5-b632-cba2ad33ecb9 . If necessary you can generateMesh from that, https://www.mathworks.com/help/pde/ug/pde.pdemodel.generatemesh.html
Ver también
Categorías
Más información sobre Geometry and Mesh 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!


