Precision in writetable()
Show older comments
Is there a way to use writetable() to export using only 2 decimals? To be able to directly export it to an excel file.
Accepted Answer
More Answers (2)
Johannes Kalliauer
on 20 Jul 2022
Edited: Johannes Kalliauer
on 20 Jul 2022
0 votes
dlmwrite('yourfile.txt',t{:,:},'\t','precision','%10.2f')
1 Comment
dpb
on 20 Jul 2022
Doesn't get OP directly to Excel as per request, though...but correct that it does allow the formatting string.
Christine
on 12 Feb 2025
Another workaround might be executing this line for the variables inside the table.
variable = round(variable*100)/100;
2 Comments
Instead of
round(pi*100)/100
use
round(pi,2)
Another I've seen has been
str2double(sprintf('%.2f',pi))
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!