How to extract each side boundary node in 2D?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?

0 Kommentare
Antworten (1)
Moksh
am 11 Sep. 2023
Bearbeitet: Moksh
am 12 Sep. 2023
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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Computational Geometry finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!