Precision in writetable()
显示 更早的评论
Is there a way to use writetable() to export using only 2 decimals? To be able to directly export it to an excel file.
采纳的回答
更多回答(2 个)
Johannes Kalliauer
2022-7-20
编辑:Johannes Kalliauer
2022-7-20
0 个投票
dlmwrite('yourfile.txt',t{:,:},'\t','precision','%10.2f')
1 个评论
dpb
2022-7-20
Doesn't get OP directly to Excel as per request, though...but correct that it does allow the formatting string.
Christine
2025-2-12
Another workaround might be executing this line for the variables inside the table.
variable = round(variable*100)/100;
2 个评论
Instead of
round(pi*100)/100
use
round(pi,2)
Another I've seen has been
str2double(sprintf('%.2f',pi))
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!