How do I export a figure from MATLAB to a document and still be able to rotate it?
조회 수: 15 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2023년 6월 26일
답변: MathWorks Support Team
2023년 6월 29일
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?
채택된 답변
MathWorks Support Team
2023년 6월 26일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!