Monday, November 11, 2013

Exporting an STL from Matlab

In this tutorial, you will learn a simple way to export a 3D image as an STL by using Matlab. The functions you'll need to make the STL file in Matlab can be found in the 1st and 2nd link below, while a more in depth tutorial can be found in the 3rd link.

LINKS:

Okay: so let's get to it.

1. Save the above two functions into Matlab.

2. Make a 3D surface plot in Matlab.
For example, type in:
    >>  [X,Y] = meshgrid(-8,0.1:8); 
    >>  R = sqrt(X.^2+Y.^2) + eps;
    >>  Z = sin(R)./R;                  
    >>  surf(X,Y,Z)                      

3. Use the surf2solid function which you downloaded earlier:
    >> VariableName = surf2solid(X,Y,Z);

4. Use the stlwrite function that you downloaded:
    >> stlwrite('FileName.stl',VariableName)  
*FileName is to be replaced with what you want to name your file

And there you have it, a nice simple way of exporting a 3D file from Matlab. 

5 comments:

  1. Hi,

    It showed an error stating Z should be a matrix not a vector/scalar quantity

    ReplyDelete
  2. Theres an error in code should be -
    >> [X,Y] = meshgrid(-8:0.1:8);
    >> R = sqrt(X.^2+Y.^2) + eps;
    >> Z = sin(R)./R;
    >> surf(X,Y,Z)

    ReplyDelete
  3. Very nice blog...
    Great information provided. We also provide Matlab Training in Noida. I appreciate your work.

    ReplyDelete
  4. Finding the time and actual effort to create a superb article like this is great thing. I’ll learn many new stuff right here! Good luck for the next post buddy..
    Matlab Training in Chennai

    ReplyDelete
  5. Online mba in India
    DEIEDU is the best online Institute in the world with high class course outline and up to date learning materials. DEIEDU is providing the online mba in india, online mba in india, Distance learning mba courses in india, Correspondence mba in India Mba from distance in India, Online Executive Mba in India, distance Mba from India, Online distance mba in India. Distance learning mba degree in India.
    Address:
    401, fourth floor sg alpha tower
    Vashundhra (up)
    Phone: 9811210788
    Email: info@deiedu.in
    Website: http://www.deiedu.in/
    online mba in india

    ReplyDelete