How do I export a figure from MATLAB to a document and still be able to rotate it?
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 26 de Jun. de 2023
Respondida: MathWorks Support Team
el 29 de Jun. de 2023
I have a nice interactive 3D figure in MATLAB and I want to export it for academic publication and presentation. Since the audience may not have access to MATLAB, how do I export such a figure from MATLAB to a document, like Word, PowerPoint or PDF, and still be able to rotate it?
Respuesta aceptada
MathWorks Support Team
el 26 de Jun. de 2023
By MATLAB R2023a this feature is not supported in MATLAB.
But you can try the following workarounds:
(1) If you would like to submit an open-source figure for people to download and play, you can simply save your figure in FIG format. People would also need MATLAB or MATLAB Online to open this FIG file and interact with it.
(2) If you would like to show the rotation of this plot during presentation, you can generate a GIF file and paste it for example into your PPTX slides for presentation purposes. Following is an example to generate a GIF:
% Example 3D plot
figure;
[X,Y,Z] = peaks;
p=surf(X,Y,Z);
xlabel('X');
ylabel('Y');
zlabel('Z');
% Set up animation parameters
numFrames = 30; % Number of frames
azimuthAngles = linspace(0, 360, numFrames); % Generate azimuth angles
% Capture frames
frames = cell(numFrames, 1);
for i = 1:numFrames
% Set view angle
view(azimuthAngles(i), 30);
% Update figure
drawnow;
% Capture frame
frames{i} = getframe(gcf);
end
% Create the GIF
filename = '3D_animation.gif';
for i = 1:numFrames
% Convert frame to indexed image
[imind, cm] = rgb2ind(frames{i}.cdata, 256);
% Write frame to GIF
if i == 1
imwrite(imind, cm, filename, 'gif', 'Loopcount', inf, 'DelayTime', 0.1);
else
imwrite(imind, cm, filename, 'gif', 'WriteMode', 'append', 'DelayTime', 0.1);
end
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Printing and Saving en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!