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

조회 수: 5 (최근 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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by