How to extract each side boundary node in 2D?

3 次查看(过去 30 天)
Discretized simple square domain but needed to extract each side separately for the boundary nodes.
How do we drag boundary nodes from this square domain?

回答(1 个)

Moksh
Moksh 2023-9-11
编辑:Moksh 2023-9-12
Hi Sasikala,
I understand that you are looking to extract the boundary nodes from a square domain defined by a set of x and y coordinates. Additionally, you want to separate each side of the square individually.
To achieve this, you can use the convhull function in MATLAB to generate the boundary points. Subsequently, you can apply arithmetic logic using the min and max functions in MATLAB to separate these boundary points into individual sides.
Here is an example code:
% Plotting a square shape
pgon = polyshape([0 0 2 2],[2 0 0 2]);
% Getting the boundary points using convex hull
polyout = convhull(pgon);
plot(pgon)
% Seperating the x and y coordinates for boundaries
x = polyout.Vertices(:, 1);
y = polyout.Vertices(:, 2);
% Separate the points for each side
side1_x = x(x == min(x));
side1_y = y(x == min(x));
side2_x = x(y == max(y));
side2_y = y(y == max(y));
side3_x = x(x == max(x));
side3_y = y(x == max(x));
side4_x = x(y == min(y));
side4_y = y(y == min(y));
Please refer to the below documentation to know more about the used functions:
Best Regards!
Moksh Aggarwal

类别

Help CenterFile Exchange 中查找有关 Industrial Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by