Creating Caps to close a tubular structure

4 ビュー (過去 30 日間)
Conor O'Keeffe
Conor O'Keeffe 2020 年 3 月 19 日
コメント済み: Star Strider 2020 年 3 月 20 日
Hi All
I have created this tubular shell structure in matlab.
I would like to create caps to close the end
[F,V] = surf2patch(x_All,y_All,z_All,'triangles');
h = patch('faces',F,'vertices',V);
set(h,'FaceColor',[0.5 0.5 0.8],'EdgeColor','k');
view(3)

採用された回答

Star Strider
Star Strider 2020 年 3 月 19 日
I cannot run your code.
Adapt this to your cylinder:
D = 10;
[X,Y,Z] = cylinder(D);
r = D;
ang = linspace(0, 2*pi);
xcirc = r*cos(ang);
ycirc = r*sin(ang);
zcirc = ones(size(ang))*max(Z(:));
figure
surf(X, Y, Z)
hold on
patch(xcirc, ycirc, zcirc, 'r')
hold off
grid on
This creates a red ‘top’ to the cylinder. To cap it on the other end, duplicate the patch call, however substituting:
zcirc = ones(size(ang))*min(Z(:));
in the second call.
  2 件のコメント
Conor O'Keeffe
Conor O'Keeffe 2020 年 3 月 20 日
Thanks @Star Strider, that worked great
Star Strider
Star Strider 2020 年 3 月 20 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!

サインインしてコメントする。

その他の回答 (1 件)

Steven Lord
Steven Lord 2020 年 3 月 19 日
It sounds like you want isocaps. See this documentation page for more information.
  1 件のコメント
Conor O'Keeffe
Conor O'Keeffe 2020 年 3 月 20 日
Hey Steven, thanks for your help. Yes, I was originally going to use that but couldnt figure out how to calculate the V part

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSimulation, Tuning, and Visualization についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by