How can I save a UIaxes-figure in a Matlab-Web-App by button callback

11 ビュー (過去 30 日間)
Thomas Anvidalfarei
Thomas Anvidalfarei 2019 年 10 月 11 日
編集済み: Benjamin Großmann 2021 年 11 月 11 日
Hy,
I would like to save a figure shown in a UIaxes of a deployed Matlab Web Aplication as png/jpeg-File in the ctfroot-directory.
example at button callback
print(app.UIaxes,'-dpng',fullfile(ctfroot,'myImage.png'))
The functionality of multiwindow to opy object to a new figure is not supported and i don't know how to access the figure in UIaxes.
Any help is appreciated
Best regards
Thomas
  2 件のコメント
Jalaj Gambhir
Jalaj Gambhir 2019 年 10 月 14 日
Hi,
Kindly refer here.
Udo Schröder
Udo Schröder 2020 年 1 月 31 日
@Jalaj
Your link does not give any solution. There the question is related to a GUI craeted with AppDesigner. This question is about WebApp GUI. The solution given in your link does not work for WebApp GUIs.
BR,
Udo

サインインしてコメントする。

回答 (1 件)

Benjamin Großmann
Benjamin Großmann 2021 年 11 月 11 日
編集済み: Benjamin Großmann 2021 年 11 月 11 日
You can use exportgraphics(obj,filename) to write a graphics object obj to filename on the web app server temporarily. Afterwards call web(fileName) to display and/or download the file in the browser.
MWE:
function PrintButtonPushed(app, event)
fileName = 'graphic.pdf';
% or query for filename:
% [fileName, ~] = uiputfile('*.pdf');
exportgraphics(app.UIAxes, fileName)
web(fileName)
end

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by