MATLAB report generator table output does not match live script table output
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Menno Merts
el 9 de Jun. de 2021
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?
Respuestas (1)
Tejas
el 28 de Feb. de 2025
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:
- Assuming the numerical data is stored in the vector 'data', use the 'sprintf' function inside the 'arrayfun' function. For more information on 'arrayfun' function, refer to this documentation: https://www.mathworks.com/help/matlab/ref/arrayfun.html .
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);
0 comentarios
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!