Need to convert data from design optimisation (in the form of a .dat file) to .stl file using "convert voxels to stl mathworks script"

14 次查看(过去 30 天)
I am new to MATLAB. I am required to use the x,y,z, coordiinates from a .dat file (consits of 1000s of rows and 3 columns) to generate a 3D stl file to open in CAD.
I require someone (maybe who has used the mathscript before) to guide me as to what file inside the script folder to edit.
Problem is, there are many files like, "Convert_voxels_to_stl.m", "Convert_voxels_to_stl_example.m", "READ.m" and "WRITE.m", "convert_meshformat.m" and an example called "Convert_voxels_to_stl_example.m".
My questions are:
  1. Which of the files should I edit or import my data into?
  2. What sort of lines should I focus on editing? Like the function arguments, or just the patching?

回答(1 个)

Jasvin
Jasvin 2023-3-7
编辑:Jasvin 2023-3-7
As per my understanding, you have the X, Y, Z data for the grid in a .dat file that you want to convert to an STL file and you are using this FileExchange submission to do the same,
If this is correct, then you should first read through the CONVERT_voxels_to_stl_example.m script to see how the function is being called and how a .stl file is generated.
The example uses a .mat file but you can use the same for .dat files, you'll just have to load it in the same way,
load(<Filename.dat>)
But if you get difficulties with this load call, then you can refer to the discussion on the following MATLAB Answer, https://www.mathworks.com/matlabcentral/answers/79885-how-to-read-tabular-data-from-dat-files-into-matlab
And then call the, CONVERT_voxels_to_stl() method.
This is what the inputs and outputs mean as per the FileExchange documentation,
Converts the voxelised object contained within the 3D logical array <gridINPUT> into an STL surface mesh, which is saved to the ascii file <STLin>. The x,y,z axes for <gridINPUT> are defined by <gridX>, <gridY> and <gridZ>. The (faces,vertices) data are optional outputs.
So you must write a new script (.m file) that first loads the .dat file which will give you the x, y and z data and then call the convert() function. And you don't have to edit any of the FileExchange files, they are intended to be used out of the box.
  1 个评论
Vikram
Vikram 2023-3-10
Hello, thanks for the information and your time.
Your assumption is correct. The x,y,z rows are 3 row vectors of data I have are randomised, and they represent a domain (like a box) and the gamma values are a single row vector of data which represents the model inside it which I want.
Although I am able to understand the concept of using the data, I am unable to come up with a MATLAB code.
It would be really helpful if you could provide me with a sample code for like 3 rows of x,y,z and gamma data, using a "reshape" or "meshgrid" statement.
Thank you.

请先登录,再进行评论。

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by