File Exchange

image thumbnail


version (967 Bytes) by Doron Harlev
Read STL file into MATLAB patch compatible matrixes.


Updated 07 Jan 2005

No License

This function reads a binary SPL file into X, Y, Z, C matrixes compatible with the MATLAB patch function.

See, , for more information on the format.

Cite As

Doron Harlev (2020). stlread (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (22)

泓程 焦

喜宽 董

How can I change the number of sampling points?

喜宽 董

w Z

very good


Chan Grown



nice code, it did work and plot beautiful graph, thanks

Yanyu Peng

nice code

Zi Tao


agdfg sdgfdg

when i'm using above code .I'm getting Error using stlread (line 16)
Not enough input arguments.
16---fid=fopen....highlighting fid

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



Please, anyone knows why do I get this MatLab errors when I try to read my STL file?

Title: solid BVMESH

facet normal 0.248 -0.299 0.922

outer loop

Num Facets: 775500593
??? Error using ==> zeros
Maximum variable size allowed by the program is exceeded.

Error in ==> stlread at 28
x=zeros(3,num_facet); y=zeros(3,num_facet); z=zeros(3,num_facet);

Thank you...

Luigi Giaccari

Althought a little slow is very useful to import stl ascii files, I think the slowness dependes on not preallocate arrays in the importation loop.

prasad k

thanks for this code
it is very useful to me
once again thanks

Abir Chakraborty

Works exactly as needed. Saves lot of time. Thanks a lot.

Tom Price

Works very nice. Thanks.

Reviewing M Files

For all the trial stl files used I get the "Error using ==> zeros
Product of dimensions is greater than maximum integer."
Please enlighten. Thanks

Reviewing M Files

Title: solid MyObj
facet normal 0.955654E-01 -0.966960E+00 0.236339E+00
Num Facets: 1886351212
??? Error using ==> zeros
Product of dimensions is greater than maximum integer.

Error in ==> E:\MyDownloads\stlread.m
On line 28 ==> x=zeros(3,num_facet); y=zeros(3,num_facet); z=zeros(3,num_facet);

Christophe Henrard

Works perfectly fine! Thank you

Zoltan Sarosi

Very good! It is exactly I was looking for. Thank you!

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

Community Treasure Hunt

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

Start Hunting!