how to turn .m into .stl if i have already a .m file

2 visualizaciones (últimos 30 días)
su chen
su chen el 23 de Mayo de 2023
Respondida: Sulaymon Eshkabilov el 23 de Mayo de 2023
so i have already have a .m file,and my teacher said that we should show it on 3D.Now,I must turn this file into stl file so i can go to the next step.But,how to use it?(P.S I am a beginner in matlab)
% define parameter
y = 0:0.001:10;
x = -pi:0.001:pi;
[X, Y] = meshgrid(x,y);
Z = Y.*sin(X);
% drawing 3D image
figure('Renderer', 'painters', 'Position', [10 10 900 600]);
h = surf(X,Y,Z);
% set the angle and gradient color
view(30, 30);
colormap(jet);
% extend the graph down by 5 units
h.ZData = h.ZData - 5;
% set the axis label and title
xlabel('x');
ylabel('y');
zlabel('z');
title('3D Plot');
pause(60);
If this code have any problems,please let me know!Thank you all!

Respuestas (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 23 de Mayo de 2023
use stlwrite - see DOC:
y = 0:0.001:10;
x = -pi:0.001:pi;
[X, Y] = meshgrid(x,y);
Z = Y.*sin(X);
% drawing 3D image
figure('Renderer', 'painters', 'Position', [10 10 900 600]);
h = surf(X,Y,Z);
% set the angle and gradient color
view(30, 30);
colormap(jet);
% extend the graph down by 5 units
h.ZData = h.ZData - 5;
% set the axis label and title
xlabel('x');
ylabel('y');
zlabel('z');
title('3D Plot');
pause(60);
stlwrite(h,'SURF.stl','text')

Categorías

Más información sobre Formatting and Annotation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by