Filter löschen
Filter löschen

Exporting Matlab App Graphs

21 Ansichten (letzte 30 Tage)
Asher
Asher am 8 Jun. 2023
Beantwortet: Asher am 15 Jun. 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 Kommentar
Asher
Asher am 8 Jun. 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)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Asher
Asher am 15 Jun. 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.

Weitere Antworten (2)

Samay Sagar
Samay Sagar am 8 Jun. 2023
Refer this to export tables as pdf.
  4 Kommentare
Asher
Asher am 9 Jun. 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 am 11 Jun. 2023
Bearbeitet: Samay Sagar am 11 Jun. 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')

Melden Sie sich an, um zu kommentieren.


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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by