Exporting Matlab App Graphs

조회 수: 30 (최근 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 CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by