Exporting UIFigure using Matlab 2020a

2 visualizaciones (últimos 30 días)
Abhishek Gaikwad
Abhishek Gaikwad el 24 de Mayo de 2022
Respondida: Satyam el 23 de Abr. de 2025
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

Respuestas (1)

Satyam
Satyam el 23 de Abr. de 2025
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!

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by