How to create a closed surface cylinder using patch function?
25 次查看(过去 30 天)
显示 更早的评论
I tried creating cylinder using patch fucntion but the top and bottom faces are open.
Below is my code-
%% Cylinder
[l,m,n]=cylinder;
fvc=surf2patch(l,m,n);
figure()
o=patch(fvc,'FaceColor','r');
o.FaceAlpha=0.2;
0 个评论
采纳的回答
Star Strider
2022-2-9
Try this —
%% Cylinder
[l,m,n]=cylinder;
figure()
surf(l,m,n)
hold on
patch(l(1,:),m(1,:),n(1,:),'r')
patch(l(2,:),m(2,:),n(2,:),'g')
hold off
title('Top End')
figure()
surf(l,m,n)
hold on
patch(l(1,:),m(1,:),n(1,:),'r')
patch(l(2,:),m(2,:),n(2,:),'g')
hold off
view(30,-30)
title('Bottom End')
The cylinder results are simply matrices of two vectors defining the top and bottom of the cylinder (unless a particular shape is supplied for the radius argument, then there are more rows to the cylinder output and only the first and last rows define the ends). To put ‘caps’ on either end, create separate patch objects for each end vector, and supply whatever colours are desired.
.
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!