Precision in writetable()
Mostrar comentarios más antiguos
Is there a way to use writetable() to export using only 2 decimals? To be able to directly export it to an excel file.
Respuesta aceptada
Más respuestas (2)
Johannes Kalliauer
el 20 de Jul. de 2022
Editada: Johannes Kalliauer
el 20 de Jul. de 2022
0 votos
dlmwrite('yourfile.txt',t{:,:},'\t','precision','%10.2f')
1 comentario
dpb
el 20 de Jul. de 2022
Doesn't get OP directly to Excel as per request, though...but correct that it does allow the formatting string.
Christine
el 12 de Feb. de 2025
Another workaround might be executing this line for the variables inside the table.
variable = round(variable*100)/100;
2 comentarios
Instead of
round(pi*100)/100
use
round(pi,2)
Another I've seen has been
str2double(sprintf('%.2f',pi))
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!