How to measure surface area layer by layer using Matlab
조회 수: 2(최근 30일)
표시 이전 댓글
i am using following code to find area of layers. I am trying but masking somewhere some mistake. Any help from community will be highly appreciated.
Attached file are the xyz-coordinates. I measure the surface area of one layer using bellow code. This coding is combining all layers. I want to find area of each layer individually. Regards to all for their cooperation and guidance.
vertices = load(' attached file ')
vertices = round(sortrows(vertices,2));
Vx = round(vertices(:,1));
Vy = round(vertices(:,2));
Vz = round(vertices(:,3));
G_surface_area =0
layer = []
surface_area = 0
for i = min(Vy):10:max(Vy) % This for loop, i am using to measure by 10 spacing.
minVy = i
for j = i:i + 9 % This measure is for layer to find its area.
layer_new = vertices(any(Vy== j,2),:);
layer = [layer; {layer_new}];
end
layer = cell2mat(layer)
Lx = layer(:,1);
Ly = layer(:,2);
Lz = layer(:,3);
surface_area = polyarea(Lx,Lz)
G_surface_area = G_surface_area + surface_area
end
댓글 수: 0
채택된 답변
KSSV
2020년 8월 22일
편집: KSSV
2020년 8월 23일
data = importdata("Cone_20000_points.txt") ;
data = round(data) ;
x = data(:,1) ; y = data(:,2) ; z = data(:,3) ;
zi = unique(z) ;
N = length(zi) ;
A = zeros(N,1) ;
tol = 10^-5 ;
for i = 1:N
idx = abs(z-zi(i))<=tol ;
% layer coordinates
xl = x(idx) ; yl = y(idx) ; zl = z(idx) ;
Layer = [x(idx) y(idx) z(idx)] ; % these are the Layer coordinates
% get boundary of layer
id = boundary(xl,yl) ;
Boundary = [xl(id) yl(id) zl(id)] ; % Boundary coordinates
A(i) = polyarea(xl(id),yl(id)) ;
end
댓글 수: 18
추가 답변(1개)
참고 항목
범주
Find more on Mathematics and Optimization 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!