View License

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

» Watch video

Highlights from
Fast STL import function

3.8 | 6 ratings Rate this file 26 Downloads (last 30 days) File Size: 2.16 KB File ID: #30923 Version: 1.0

Fast STL import function


Eric Trautmann (view profile)


Function to import .stl geometry model files into matlab.

| Watch this File

File Information

This version is currently ASCII only but future revisions will support binary. This function is based off of Luigi Giaccari's STL importer but uses the textscan function to dramatically increase speed, which makes a significant difference for large files.

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (11)
13 Nov 2015 Brian Guthrie

I have the same problems: removed all'\r' in line 47. I get two errors:
>import_stl_fast(filename, 1)
>Error using import_stl_fast (line 31)
>invalid input number /mode setting
>> import_stl_fast(filename, 2)
Subscript indices must either be real positive integers or logicals.

Error in import_stl_fast (line 61)
if (C{4}(end)== NAN)

Comment only
15 Sep 2015 Carlos

Carlos (view profile)

Once I changed line 47 it works great! Super fast!

Solution: in line 47 'fmt = ...' remove all the '\r'. Those might be needed in Windows?

08 Sep 2015 Muhammad Ahsan Ansari

Hello Dear,

You have written a very useful code for stl files.

However, i have one question.

How to display the output after reading an stl file. as i tried patch to display it but it is not displaying the correct model which i gave as input.

can you tell me how to display the output of your function? or do we need any conversion before that?

Comment only
31 May 2015 Andrew Hundt

I too am getting this error. Anyone have a solution?

02 Nov 2014 Fritz

Fritz (view profile)

@Pierrick Bersier: I'm getting the same error.

Comment only
06 Sep 2014 Pierrick Bersier

When I try to load my STL with that script, I get every time the same error. an sombody help ?

Subscript indices must either be real positive integers or logicals.

Error in import_stl_fast (line 59)
if (C{4}(end)== NaN)

Comment only
05 Jan 2014 Ilkay Meseli

28 Aug 2013 Emmanuel Farhi

Works OK for ASCII STL files. Thanks.

08 Apr 2013 Christian Kotz

19 Apr 2012 Morteza Shahpari

05 Apr 2011 Eric Trautmann

Eric Trautmann (view profile)

If any current users are interested in a binary stl import, please let me know.

Comment only

Contact us