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!