# How to divide the cylinder into layers and then measure the volume of each layer???

조회 수: 3(최근 30일)
M.S. Khan 2020년 8월 30일
HI honorable members of matlab, i am trying to measure volume of cylinder using layers. I have measure the volume of cylinder using conhull function but i want to divide the the cylinder into layers having certain thickness. Then i want to measure volume of each layer or slice. The sum of volume of all layers should give me the same volume as a cylinder.
h = 20; % height
% Create constant vectors
tht = linspace(0,2*pi,100)
z = linspace(0,h,20)
% Create cylinder
xa = repmat(ra*cos(tht),20,1)
ya = repmat(ra*sin(tht),20,1)
za = repmat(z',1,100)
% To close the ends
X = [xa*0; flipud(xa); (xa(1,:))*0]
Y = [ya*0; flipud(ya); (ya(1,:))*0]
Z = [za; flipud(za); za(1,:)]
% Draw cylinder
[TRI,v]= surf2patch(X,Y,Z,'triangle')
patch('Vertices',v,'Faces',TRI,'facecolor',[0.5 0.8 0.8],'facealpha',0.8)
view(3); grid on; axis square; title('Cylinder','FontSize',12)
%% Volume using convhull() function
[~,V]=convhull(X,Y,Z)
%% volume measure using the formula
volume_cylinder = pi * ra^2 * h

댓글을 달려면 로그인하십시오.

### 범주

Find more on Recognition, Object Detection, and Semantic Segmentation 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!