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

0 Stimmen

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

0 Stimmen

Refer this to export tables as pdf.

4 Kommentare

Asher
Asher am 8 Jun. 2023
This solution does not work for me. I think it is because it doesnt work in app designer? Regardless, here is the error that appears when I try to implement this.
Error using uitable
Functionality not supported with figures created with the figure function.
t = uitable(fig,'Data', app.fuelTable);
Samay Sagar
Samay Sagar am 9 Jun. 2023
You need to create fig using uifigure. You can refer this doc.
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

0 Stimmen

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 Printing and Saving finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2023a

Gefragt:

am 8 Jun. 2023

Beantwortet:

am 15 Jun. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by