Precision in writetable()
Afficher commentaires plus anciens
Is there a way to use writetable() to export using only 2 decimals? To be able to directly export it to an excel file.
Réponse acceptée
Plus de réponses (2)
Johannes Kalliauer
le 20 Juil 2022
Modifié(e) : Johannes Kalliauer
le 20 Juil 2022
0 votes
dlmwrite('yourfile.txt',t{:,:},'\t','precision','%10.2f')
1 commentaire
dpb
le 20 Juil 2022
Doesn't get OP directly to Excel as per request, though...but correct that it does allow the formatting string.
Christine
le 12 Fév 2025
Another workaround might be executing this line for the variables inside the table.
variable = round(variable*100)/100;
2 commentaires
Instead of
round(pi*100)/100
use
round(pi,2)
Another I've seen has been
str2double(sprintf('%.2f',pi))
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!