How to extract each side boundary node in 2D?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Moksh
el 11 de Sept. de 2023
Editada: Moksh
el 12 de Sept. de 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 comentarios
Ver también
Categorías
Más información sobre Computational Geometry en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!