File Exchange

image thumbnail

Function for importing and plotting STL files in MATLAB

version (1.54 KB) by siddhesh rane
This file will import and plot ASCII STL file in MATLAB.


Updated 23 May 2013

View License

The file may not be time and space efficient but i think its well documented and can be easily understood by beginners.To avoid complexity file does not consider normal vectors.

Cite As

siddhesh rane (2020). Function for importing and plotting STL files in MATLAB (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)


Worked with a little bit of a change, as my STL had multiple solids included in it. As a result, the parsing for m did not work properly. Had to include the following change:

while isnan(junk)
and remove the m=m+9; line after the j loop.

Maxime Fauconnier

The only function that works for me. Thanks !
And with the Eric Ludlam's code snippet, I can obtain what I intended. Thank you to both of you.

Danesh Bankwala

Crashed and has inadequate documentation to understand what went wrong, so I could not even patch it.


Tried a lot of the functions available. This was the only one that ran error free. Thanks mate!!

mohammad eslami

Ron Perrone

Unfortunately this function didn't work for me. Wouldn't read the file.

Error in readSTL (line 4)

Open to suggestions?

Eric Ludlam

I like this simple reader which worked great for output from openSCAD.

I used this code snippet to convert the coordinate return value into something I could drop right onto a patch object:

verts = reshape(coordinates,3,[])';
tri = reshape(1:size(verts,1),3,[])';

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux