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)
Show older comments
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 Comments
Answers (1)
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
2 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!