Exporting Matlab App Graphs

30 visualizzazioni (ultimi 30 giorni)
Asher
Asher il 8 Giu 2023
Risposto: Asher il 15 Giu 2023
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 Commento
Asher
Asher il 8 Giu 2023
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)

Accedi per commentare.

Risposta accettata

Asher
Asher il 15 Giu 2023
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.

Più risposte (2)

Samay Sagar
Samay Sagar il 8 Giu 2023
Refer this to export tables as pdf.
  4 Commenti
Asher
Asher il 9 Giu 2023
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 il 11 Giu 2023
Modificato: Samay Sagar il 11 Giu 2023
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')

Accedi per commentare.


Simon Chan
Simon Chan il 11 Giu 2023
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 Commento
Asher
Asher il 12 Giu 2023
I appreciate it! Unfortunately, getframe is an option that doesnt work with the compiler.

Accedi per commentare.

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by