File Exchange

## Function for importing and plotting STL files in MATLAB

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

Updated 23 May 2013

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 (https://www.mathworks.com/matlabcentral/fileexchange/41910-function-for-importing-and-plotting-stl-files-in-matlab), MATLAB Central File Exchange. Retrieved .

James

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:

junk=str2double(C{1,1}{m,1});
while isnan(junk)
m=m+1;
junk=str2double(C{1,1}{m,1};
end
coordinates(i,1)=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!!

Ron Perrone

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

fid=fopen(Practice_epiphysis);

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