How to fill a triangle in an circular mesh in pdeplot?

1 回表示 (過去 30 日間)
Boni_Pl
Boni_Pl 2019 年 6 月 6 日
回答済み: AKennedy 2025 年 1 月 2 日
Hello sir
I have an circular mesh. Inside the mesh I have another circle.Now how to fill the circle? In the circle there are 4 triangle element and the cicular mesh have 268 elements. Please help me.

回答 (1 件)

AKennedy
AKennedy 2025 年 1 月 2 日
From what you have described, here's how I would approach it
  1. Identify the Inner Circle Elements: Determine which elements (triangles) belong to the inner circle.
  2. Plot the Mesh: Use the patch function to plot the mesh and fill the inner circle.
% Sample data: Adjust these arrays based on your actual mesh data
% Nodes of the mesh (example coordinates)
nodes = [
0, 0;
1, 0;
0.5, 0.5;
0, 1;
% ... (add more nodes as needed)
];
% Connectivity of the mesh elements (example indices)
elements = [
1, 2, 3;
1, 3, 4;
% ... (add more elements as needed)
];
% Elements belonging to the inner circle
inner_circle_elements = [1, 2, 3, 4]; % Example indices of inner circle elements
% Plot the full mesh
figure;
hold on;
for i = 1:size(elements, 1)
% Extract node indices for the current element
node_indices = elements(i, :);
% Get the coordinates for the nodes of the element
x = nodes(node_indices, 1);
y = nodes(node_indices, 2);
% Plot the element
patch(x, y, 'w'); % 'w' for white; adjust color as needed
end
% Fill the inner circle elements
for i = inner_circle_elements
% Extract node indices for the current inner circle element
node_indices = elements(i, :);
% Get the coordinates for the nodes of the element
x = nodes(node_indices, 1);
y = nodes(node_indices, 2);

カテゴリ

Help Center および File ExchangeTriangulation Representation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by