Hi, i drew 4 cylinders, while removing a part from each and sticking them together. However, the cylinders are hollow and i want to at least have a bottom and top lid (same shape as the cylinders) if not fully fill it in 3D. Any help would be nice.
1 回表示 (過去 30 日間)
古いコメントを表示

h=figure(1);
set(h, 'WindowStyle', 'docked')
drawnow
for i=0:1.5:6
[x,y,z]= cylinder(1,1000);
z(:,386:617)=NaN;
x(:,386:617)=NaN;
y(:,386:617)=NaN;
h=surf(x+i,y,z, 'FaceColor', [0,0,1]);
hold on
end
0 件のコメント
回答 (1 件)
KSSV
2016 年 10 月 7 日
clc; clear all ;
h=figure(1);
set(h, 'WindowStyle', 'docked')
th = linspace(0,2*pi) ;
R = 1 ;
for i=0:1.5:6
[x,y,z]= cylinder(1,100);
% draw circle
% z(:,386:617)=NaN;
% x(:,386:617)=NaN;
% y(:,386:617)=NaN;
% draw circle
xc = i+R*cos(th) ; yc = R*sin(th) ;
% top cirlce z
zc1 = ones(size(xc)) ;
% bottom cricle
zc0 = zeros(size(xc)) ;
h=surf(x+i,y,z, 'FaceColor', [0,0,1]);
hold on
patch(xc,yc,zc0,'r')
patch(xc,yc,zc1,'r')
end
2 件のコメント
参考
カテゴリ
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!