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.

2 次查看(过去 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

回答(1 个)

KSSV
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

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by