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?
0 件のコメント
回答 (1 件)
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Industrial Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!