Clear Filters
Clear Filters

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 views (last 30 days)
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

Answers (1)

KSSV
KSSV on 7 Oct 2016
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

Tags

Community Treasure Hunt

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

Start Hunting!