MATLAB report generator table output does not match live script table output

조회 수: 2 (최근 30일)
Klemen Knez
Klemen Knez 2021년 4월 14일
답변: Tejas 2025년 2월 28일
I am writing automated .pdf report. Everything expect one thing works perfectly. I want to have only two decimals in my pdf table output. I can only achieve that with string or char but then apostrophe stays in table output like you can see in Picture1. What could be the solution?
  댓글 수: 1
Menno Merts
Menno Merts 2021년 6월 9일
Having the same issue. My script used to generate nice reports, but now all table entries have a single or double apastrophe around them. Any idea where this comes from?

댓글을 달려면 로그인하십시오.

답변 (1개)

Tejas
Tejas 2025년 2월 28일
Hello Klemen,
It seems the goal is to show numerical data with up to two decimal places in a table within the generated report. This can be done using the 'sprintf' function, which formats numbers into strings with the desired precision. More information on this function, is available in the documentation: https://www.mathworks.com/help/matlab/ref/string.sprintf.html .
Here are steps,to achieve the desired formatting:
formattedData = arrayfun(@(x) sprintf('%.2f', x), data, 'UniformOutput', false);
  • Convert the data into a table and include it in the report.
table = Table(formattedData);
add(rpt, table);

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by