フィルターのクリア

Exporting Matlab App Graphs

21 ビュー (過去 30 日間)
Asher
Asher 2023 年 6 月 8 日
回答済み: Asher 2023 年 6 月 15 日
I have built an app using the Matlab App Designer. This app produces a couple of graphs on the screen, and now I want to export them to a PDF.
I am currently writing the code shown below. I am getting Error Uncrecognized method, property, or field 'UItable for class 'AnalyzerApp', where Analyzer app is the name of the app I am making.
For reference, path is the location that I want to save the pdf to.
exportgraphics(app.UItable, path)
exportgraphics(app.UItable2, path, 'Append', True)
exportgraphics(app.Axes, path, 'Append', True)
exportgraphics(app.Axes2, path, 'Append', True)
exportgraphics(app.Axes3, path, 'Append', True)
exportgraphics(app.Axes4, path, 'Append', True)
exportgraphics(app.Axes5, path, 'Append', True)
exportgraphics(app.Axes6, path, 'Append', True)
exportgraphics(app.Axes7, path, 'Append', True)
  1 件のコメント
Asher
Asher 2023 年 6 月 8 日
Below is what I have found to work best so far, but still no luck. The first two that I am trying to print are tables, and they do not export - instead turning into blank pages. However, this does successfully export the graphs. I have been using this as reference Compare Ways to Export Graphics from Figures - MATLAB & Simulink (mathworks.com), however it seems that exportgraphics is the only one of those 4 options that can run through the matlab compiler... If anyone has tips on how to export the tables successfully let me know!
exportgraphics(app.FuelTable, "Cycle #" + app.cycleNo + ".pdf")
exportgraphics(app.DefuelTable, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)
exportgraphics(app.FuelPressureTab, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)
exportgraphics(app.FuelMassflowTab, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)
exportgraphics(app.FuelDispTempTab, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)
exportgraphics(app.FuelTankTempTab, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)
exportgraphics(app.DefuelPressureTab, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)
exportgraphics(app.DefuelTankTempTab, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)
exportgraphics(app.DefuelMassflowTab, "Cycle #" + app.cycleNo + ".pdf", 'Append', true)

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

採用された回答

Asher
Asher 2023 年 6 月 15 日
After speaking with a matlab representative, it seems the only way to properly export a table to a PDF in app designer, while keeping compiler functionality, is to write it using the report generator. Once you have report generator, there is plenty of clear documentation on how to solve this exact problem.

その他の回答 (2 件)

Samay Sagar
Samay Sagar 2023 年 6 月 8 日
Refer this to export tables as pdf.
  4 件のコメント
Asher
Asher 2023 年 6 月 9 日
Still doesnt work. To be clear, Matlab doesnt read uitables as a graphic. That is why I am looking for alternatives. Even if you put a uitable in a uifigure, or a normal figure, Matlab CANNOT read a uitable as a graphic.
Error using exportgraphics
Unable to export. Figure must contain graphics.
exportgraphics(fig, fullFilePath) % uitable('Data', app.fuelTable) %'ColumnName', headers
Samay Sagar
Samay Sagar 2023 年 6 月 11 日
編集済み: Samay Sagar 2023 年 6 月 11 日
To save table as pdf you don't need to use exportgraphics func. You can use saveas func to store table as pdf. You should be able to use the generated pdf to store your graphs since they do have graphic content using exportgraphics. You can store table as pdf like this:
fig = figure('Name','Numbers');
t = uitable(fig,'Data',[2,4,6,8;1,3,5,7]);
saveas(gcf,'Numbers','pdf')

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


Simon Chan
Simon Chan 2023 年 6 月 11 日
Use function getframe is an alternative option.
It captures the screen according to the uitable position and put on a traditional figure. After that, use function exportgraphics to put it on a pdf file.
You may adjust the screen capture positions according to your own needs.
Attached an example for your reference.
  1 件のコメント
Asher
Asher 2023 年 6 月 12 日
I appreciate it! Unfortunately, getframe is an option that doesnt work with the compiler.

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

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by