View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
STL File Reader

4.4 | 29 ratings Rate this file 311 Downloads (last 30 days) File Size: 1.6 MB File ID: #22409 Version: 1.2
image thumbnail

STL File Reader


Eric Johnson (view profile)


11 Dec 2008 (Updated )

STLREAD imports geometry from a binary stereolithography (STL) file into MATLAB.

| Watch this File

File Information

In addition to the STLREAD import function, this submission also includes a small demo that loads an STL model of a human femur bone.

FV = STLREAD(FILENAME) imports triangular faces from the binary STL file
indicated by FILENAME, and returns the patch struct FV, with fields 'faces'
and 'vertices'.

[F,V] = STLREAD(FILENAME) returns the faces F and vertices V separately.

[F,V,N] = STLREAD(FILENAME) also returns the face normal vectors.

The faces and vertices are arranged in the format used by the PATCH plot


This file inspired Binary Stl File Reader, Polarizability Gui5, Stl Tools, and User Controlled 3 D Airplane Animation Set Of Examples.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (37)
22 Feb 2017 Max Hardwick-Morris

Hi Eric,

When I run this demo I get an error message "Undefined function or variable 'stlread'."

Is there a toolbox I may be missing to run this stlread function?

Thank you in advance!

Comment only
08 Feb 2017 Andrea Menichetti

Thank you! It worked for me at first attempt!

08 Feb 2017 André Brito

08 Feb 2017 André Brito

26 Jan 2017 Steffen Ossmann

14 Jan 2017 AN DUONG HOAI

16 Nov 2016 Brandon Jones

I have been attempting to convert CAD files to MATLAB for the past week. I have gone through a half dozen xml and iges toolboxes and none worked. This program worked the first time I tried it and has an easy to understand interface. Thank you.

11 Nov 2016 Victoria Hung

thank you so much! that's really useful and impressive!

Comment only
19 Jul 2016 Iñigo Moreno

@Evan That is because the vertices appear one time for each face, try running:

[v, ~, index] = unique(v, 'rows');
f = index(f);

14 Jun 2016 Ron Perrone

Does anyone have any suggestions for any other files that can do this? Can't seem to get this one to work. The demo didn't work either. Looks good, but need one that is a little more user friendly. Any suggestions are greatly appreciated. Im sure this one is 5 stars for those who can get it to work.

Comment only
14 Jun 2016 Evan Terrell

Great function, but one problem. When I open my stl in a mesh editor, the surface has 55,000 vertices. However, when I read the file into Matlab with this script, there are nearly 330,000 vertices. Any idea what the problem is?

Comment only
13 Jun 2016 Ron Perrone

Unfortunately this script wouldn't run for me. Keeps saying more input requirements are needed to run, even though I have the correct name of the file.

Comment only
31 May 2016 wayclif jordan


16 May 2016 Di Zhu

Di Zhu (view profile)

works well

12 May 2016 hao gu

hao gu (view profile)

deeply impressed

06 Apr 2016 j p

j p (view profile)

Excellent!! but only support binary format.

27 Feb 2016 Brad Saund

05 Feb 2016 Omar Osama

07 Jul 2015 Michael Volk

How do I get this to work?

09 Jun 2015 James

James (view profile)

Worked like a charm on a very complex SE-translated STL file.

20 Feb 2015 Todd Brintlinger

This function is for binary STLs only, and will cause problems when used with ascii STL. The conditional statement against reading ascii STLs is commented out.

26 Nov 2014 Arne

Arne (view profile)

what is meant by faces and vertices?

I want to generate a 3D-array out of my STL-files.. is there a way?

Comment only
25 Sep 2014 Charles Eloquin Leclerc

Memory expensive, the script quickly crash because the computer is out of memory. The script extract about a billion points from my STL files. From my calculation, I would need about 100 Gb of ram......

Does someone have a solution for this problem?

05 May 2014 negar

negar (view profile)

Hi. thanks for this program. can you send me flowchart?
Best regards.

22 Jul 2013 Saber

Saber (view profile)

Great work!

08 Apr 2013 Christian Kotz

Great! fast and easy to use.

23 Dec 2012 Héctor Corte

Wonderful submision. I used it to make some geek gif in my blog.

08 Jun 2012 Patrick

Very helpful

23 Dec 2011 Santosh ARS

i think this gives wrong faces? Please confirm.

Comment only
15 Dec 2011 Robert

Robert (view profile)

Thanks for your submittal. What units is the model in once I've read the stl file with Matlab. I am using NextEngine's 3D scanner and they are telling me that the units are defined by the reader utility.

12 Dec 2011 Morteza Shahpari

11 Dec 2011 Morteza Shahpari

Very nice and useful.

05 Jan 2011 Francis Esmonde-White

I have re-written this function to be much faster.


Comment only
04 Jan 2010 By ?

By ? (view profile)

very good

22 Jan 2009 Luigi Giaccari

Very useful for binary filesl but do not support ascii format

16 Jan 2009 Jveer

Jveer (view profile)

very useful!

can the vertices and faces be arranged such that they can be used with surf??

textures cannot be applied to patch objects. surf is more useful.

12 Dec 2008 alain boyer

31 Dec 2009 1.1


20 Jul 2011 1.2

Updated submission with example script and 3D model.

Contact us