How to generate multiple .stl files in a loop?
Afficher commentaires plus anciens
My core question is: How to write multiple .stl files.
What I am doing here is: Open a .stl file (Code line 1), then rotate it in randomly generated axis (Code lines: 2 : 16) and finally write 10 .stl files.
When I run my codes, in command window it show 10 files succesfully written, but when I check in directory it shows only 1 file.
I think there is something wrong with the way I am try to use stlread (function) in for loop to write multiple .stl files.
[F,V,N] = stlread ('Directory_name:\Model_STL_Binary_0_0_0.stl'); %.stl file location
theta_x = randi ([0,180],10,1);
theta_y = randi ([0,180],10,1);
theta_z = randi ([0,180],10,1);
T = table(theta_x,theta_y,theta_z);
theta_angles =table2array(T);
ax = deg2rad(theta_angles(:,1));
ay = deg2rad(theta_angles(:,2));
az = deg2rad(theta_angles(:,3));
for i= 1:length(theta_angles)
Rx = [ 1, 0, 0 ; 0, cos(ax(i)), -sin(ax(i)); 0, sin(ax(i)), cos(ax(i))];
Ry = [ cos(ay(i)), 0, sin(ay(i)) ;0, 1, 0 ; -sin(ay(i)), 0, cos(ay(i)) ];
Rz = [ cos(az(i)), -sin(az(i)), 0 ; sin(az(i)), cos(az(i)), 0 ; 0, 0, 1 ];
pointR1 = V*Rx;
pointR2 = pointR1*Ry;
pointR3 = pointR2*Rz;
stlwrite('check.stl', F, pointR3(:,1:3));
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur STL (STereoLithography) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!