How to measure surface area layer by layer using Matlab

조회 수: 2 (최근 30일)
M.S. Khan
M.S. Khan . 2020년 8월 22일
댓글: M.S. Khan . 2020년 8월 24일
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}];
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

채택된 답변

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)) ;
  댓글 수: 18
KSSV 2020년 8월 23일
Boundary = cell2mat(Boundary(:));

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

추가 답변 (1개)

M.S. Khan
M.S. Khan 2020년 8월 24일
Hi Dear KSSV, along with your code, i followed following procedure ( hints from Mr. Uday) to generate the traingulated mesh of the cone. Then i estimated the area of triangulated cone. could you please guide, am i correct??
bx = Boundary(:,1) ; by = Boundary(:,2) ; bz = Boundary(:,3) ;
T = delaunay(bx, by)
TO = triangulation(T, bx(:),by(:),bz(:)); %creates a 3-D triangulation representation with the point coordinates specified as column vectors X, Y, and Z
trimesh(TO) %plots the triangular mesh
%It will mesh the cone with triangles.
%Get the area of each triangle and sum them.
% This will give you surface area.
%% How to find area
area = 0; %initialize the area
%loop over all the desired small triangles and accumulate the areas
for i = 1:size(TO.ConnectivityList,1) %the number of rows gives the number of triangles produced
a = TO.Points(TO.ConnectivityList(i,:),:); %this gives the 3 vertices of the ith triangle
if any(a(:,3) > max(bz))
continue; %if the triangle has a vertex whose z - coordinate is > 0.4 ignore it
%extract the three vertices
p1 = a(1,:);
p2 = a(2,:);
p3 = a(3,:);
format compact
area = area + 0.5 * norm(cross(p2-p1,p3-p1)); %calculate the area of the small triangle and add with previous result
  댓글 수: 4
M.S. Khan
M.S. Khan 2020년 8월 24일
This area is in pixels, right. Do you have any idea how to convert them into mm^2.

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


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