Exporting UIFigure using Matlab 2020a

1 次查看(过去 30 天)
Hello all,
I have created an app which displays some data upon clicking some buttons. I want to save the UIFigure (with all the data) as a pdf or a jpg file. I know that for Matlab 2020b and onwards, there is the 'exportapp'. However, I am using Matlab 2020a and was wondering what alternatives exist to save the app UI as a pdf or an image. I tried using the following command: exportgraphics('app.UIFigure','screenshot.jpg') but this gives a blank jpg image.
Thank you for your time.
Kind Regards,
Abhishek

回答(1 个)

Satyam
Satyam 2025-4-23
Hi Abhishek,
I faced a similar issue in MATLAB R2020a but I observed that it was working fine with MATLAB R2020b onwards. So, a possible fix could be to try upgrading MATLAB to a newer version. There is also a workaround which I found, instead of passing 'app.UIFigure', I tried passing a component inside it which in my case was the axes object 'app.UIAxes' and it was working fine with it.
% Button pushed function: Button
function ButtonPushed(app, event)
% Plot some data
plot(app.UIAxes, rand(1,10));
app.Label.Text = 'Data Plotted!';
end
% Button pushed function: SaveImageButton
function SaveImageButtonPushed(app, event)
figure(app.UIFigure);
exportgraphics(app.UIAxes,'screenshot.jpg') %Works Fine
end
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by