How to show Edgelabels in PDE Toolbox of particular face only
Mostrar comentarios más antiguos
I have created 2D geometry with combining one rectangle and one triangle with code to solve a problem in matlab pdetoolbox
% geometry
topLayer = [3 4 0 2 2 0 0 0 1.5 1.5];
TriLayer = [2 3 1 1.5 0.5 0.7 1.5 1.5 0 0];
gdm = [topLayer;TriLayer]';
[d1,bt] = decsg(gdm,'R1+R4',['R1';'R4']');
figure
pdegplot(d1,"EdgeLabels","on", "FaceLabels","on")
now after running above code it shows 2 face with all edge labels, but my concerned is to show only F2 edgelabels, i.e., only triangle facelabels how to do that.
the reason to know this answer is because; after solving complete problem in matlab pde toolbox we get 2D solution plot using pdeplot function; now let say pressure distribution; now on that plot using "hold on", I want to highlight/plot the triangle (F2) edges as to see how the pressure distribution in F2 compared to F1.
i think i am clear with my problem; please let me know anything required
Respuestas (1)
Malay Agarwal
el 30 de Dic. de 2024
Editada: Malay Agarwal
el 30 de Dic. de 2024
While it is not possible to plot specific edges that belong to a face using pdeplot directly, you can highlight the edges with a different color.
The decomposed geometry matrix d1 is a
matrix. The rows 2 to 5 of the matrix have the coordinates of the edges in each column, where:
- 2nd row has the starting x-coordinate of the edge.
- 3rd row has the ending x-coordinate of the edge.
- 4th row has the starting y-coordinate of the edge.
- 5th row has the ending y-coordinate of the edge.
If you can identify which edges belong to a particular face, you can use the plot() function to then plot those edges with a different color. To identify the edges which belong to a particular face, you can use the faceEdges() function. Since it expects a geometry, you will first have to convert the decomposed geometry matrix to a geometry using the geometryFromEdges() function.
The following code shows how to achieve this:
topLayer = [3 4 0 2 2 0 0 0 1.5 1.5];
TriLayer = [2 3 1 1.5 0.5 0.7 1.5 1.5 0 0];
gdm = [topLayer; TriLayer]';
[d1, bt] = decsg(gdm, 'R1+R4', ['R1'; 'R4']');
figure
pdegplot(d1,"FaceLabels","on", "EdgeLabels", "on") % Plot with face labels but no edge labels initially
% Convert the decomposed matrix to edges
gm = geometryFromEdges(d1);
% Change this to highlight different faces
face_num = 2;
% Obtain the indices of the edges that belong to the face
edges = faceEdges(gm, face_num);
% Obtain the coordinates of the edges from the decomposed matrix
faceEdgeCoords = d1(2:5, edges);
% Plot each edge with a thicker red line
hold on;
for i = 1 : size(faceEdgeCoords, 2)
plot(faceEdgeCoords(1:2, i), faceEdgeCoords(3:4, i), 'r-', 'LineWidth', 2);
end
hold off;
Refer to the following resources for more information:
- Details on the decomposed geometry matrix - https://www.mathworks.com/help/releases/R2023a/pde/ug/decsg.html#bu_fft3-dl
- geometryFromEdges() function -https://www.mathworks.com/help/releases/R2023a/pde/ug/pde.pdemodel.geometryfromedges.html
- faceEdges() function - https://www.mathworks.com/help/releases/R2023a/pde/ug/discretegeometry.faceedges.html
Hope this helps!
1 comentario
Gobinda Debnath
el 30 de Dic. de 2024
Editada: Gobinda Debnath
el 30 de Dic. de 2024
Categorías
Más información sobre Geometry and Mesh en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




