How can I save Matlab FEM mesh information to *.stl or *.ply

7 views (last 30 days)
Hi omnipotent expert,
I encountered some issues after writing Matlab FEM mesh information into *.stl or *.ply then try to import it to some mesh handling software, such as Space Claim, Icem, etc. But these software can not correctly open *.stl or *.ply file from Matlab saved results. Did anybody have workful experience of transter these data to these mesh handling software or other software? Please share these experience, thank you.

Accepted Answer

Shubham on 22 Feb 2024
Hi Bin,
There could be some compatibility issues when importing the mesh generated in MATLAB into other third-party software. Before exporting the mesh, try validating it first.
Remove duplicate points present in mesh. You can use the “unique” function to obtain unique rows in a matrix. Refer to the following code snippet:
% Find the unique vertices and their indices
[uniqueVertices, ~, indexn] = unique(V, 'rows', 'stable');
% Map the face indices to the new set of vertices
newFaces = indexn(F);
For more information on “unique” function, you can refer to the following documentation:
You can assess the quality of Mesh objects using the “meshQuality” function present in PDE toolbox documentation:
Align mesh normal to point in a consistent direction using the unifyMeshNormalsFile Exchange submission:
Finally, check the file format required for importing the mesh. You can write in ASCII and binary format. Refer to the following File Exchange function “stlwrite” which can be used to write in both file formats:
I hope this helps!

More Answers (0)




Community Treasure Hunt

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

Start Hunting!