How to Extracting Only Surface Coordinates from a 3D STL File in MATLAB?

22 views (last 30 days)
Hello MATLAB Community,
I've created a 3D model in SolidWorks and I'm currently trying to import it into MATLAB to extract the coordinates of points that lie only on the model's surface.
I've been utilizing the generateMesh function from the Partial Differential Equation Toolbox. However, this method seems to be including points from the interior of the model as well.
I have attached the STL file of my model. Could anyone guide me on how to modify my approach so that I only obtain the coordinates of the surface points?
Thanks!

Answers (1)

Star Strider
Star Strider on 21 Mar 2024
See if the trisurf function does what you want —
Uz = unzip('22G teardrop COMSOL.zip');
filename = Uz{:};
[TR,fileformat,attributes,solidID] = stlread(filename);
P = TR.Points;
T = TR.ConnectivityList;
Q = [P(1:10,:) T(1:10,:)];
figure
trisurf(T, P(:,1), P(:,2), P(:,3), 'EdgeColor','none')
colormap(turbo)
axis('equal')
view(120,45)
Ax = gca;
Ax.Visible = 'off';
.

Community Treasure Hunt

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

Start Hunting!