Precision in writetable()
Mostra commenti meno recenti
Is there a way to use writetable() to export using only 2 decimals? To be able to directly export it to an excel file.
Risposta accettata
Più risposte (2)
Johannes Kalliauer
il 20 Lug 2022
Modificato: Johannes Kalliauer
il 20 Lug 2022
0 voti
dlmwrite('yourfile.txt',t{:,:},'\t','precision','%10.2f')
1 Commento
dpb
il 20 Lug 2022
Doesn't get OP directly to Excel as per request, though...but correct that it does allow the formatting string.
Christine
il 12 Feb 2025
Another workaround might be executing this line for the variables inside the table.
variable = round(variable*100)/100;
2 Commenti
Instead of
round(pi*100)/100
use
round(pi,2)
Another I've seen has been
str2double(sprintf('%.2f',pi))
Categorie
Scopri di più su Spreadsheets in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!