How can I save the stl file from Matlab?

조회 수: 85 (최근 30일)
Parmi Granmaye
Parmi Granmaye 2023년 9월 8일
댓글: Parmi Granmaye 2023년 9월 13일
Hi
I want to download the office.stl file from matlab. How can I do that?
Thanks

답변 (1개)

Shubham
Shubham 2023년 9월 11일
Hi Parmi,
I understand that you want to download the stl file from MATLAB.
To download the office.stl file from MATLAB, you can follow these steps:
  1. Open MATLAB and make sure you have the STL file loaded or generated in your workspace.
  2. Use the stlwrite function to save the STL file to your desired location. The function syntax is as follows:
stlwrite(filename, fv)
  • filename is the name of the STL file you want to save, including the file extension (e.g., 'office.stl').
  • fv is a structure representing the triangulated mesh of your office object. Make sure you have this structure defined before using the stlwrite function.
After calling the stlwrite function, the STL file will be saved to the specified location. You can then access it through your file explorer or any file management tool.
Here's an example of how you can use the stlwrite function to save the office.stl file:
% Assuming you have already defined the triangulated mesh of the office object as 'fv'
filename = 'office.stl';
stlwrite(filename, fv);
Make sure to replace 'fv' with the actual variable name representing the triangulated mesh of your office object.
Remember to adjust the code accordingly based on your specific scenario.
I hope this helps!
  댓글 수: 3
Shubham
Shubham 2023년 9월 11일
Hi Parmi,
Here is the example for stlwrite function:
% Define the vertices and faces for a simple cube
vertices = [0 0 0; 1 0 0; 1 1 0; 0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1];
faces = [1 2 3; 1 3 4; 2 6 7; 2 7 3; 6 5 8; 6 8 7; 5 1 4; 5 4 8; 4 3 7; 4 7 8; 5 6 2; 5 2 1];
% Convert face-vertex structure to a triangulation object
TR = triangulation(faces, vertices);
% Save the triangulation object as an STL file
filename = 'cube.stl';
stlwrite(TR,filename, 'text');
In this code snippet, we define the vertices and faces for a simple cube. The vertices matrix contains the coordinates of the eight vertices, and the faces matrix defines the connectivity of the vertices to form the six faces of the cube.
Next, we create a triangulation object TR using the triangulation function, passing the faces and vertices matrices as inputs. This triangulation object represents the geometry of the cube.
Finally, we save the triangulation object TR as an STL file named "cube.stl" using the stlwrite function. The third argument 'text' specifies that the STL file should be saved in text format.
The resulting STL file will contain the information about the cube's geometry, including the vertices and faces, in a human-readable text format.
I hope this helps!
Parmi Granmaye
Parmi Granmaye 2023년 9월 13일
Hi Shubham,
Thank you so much for your helpful answer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 STL (STereoLithography)에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by