How do I export a figure from MATLAB to a document and still be able to rotate it?

12 ビュー (過去 30 日間)
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
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 件)

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by