MATLAB Answers

Precision in writetable()

35 views (last 30 days)
madhan ravi
madhan ravi on 26 Oct 2020
Commented: madhan ravi on 26 Oct 2020
Is there a way to use writetable() to export using only 2 decimals? To be able to directly export it to an excel file.


Sign in to comment.

Accepted Answer

dpb on 26 Oct 2020
Sadly, no. A OutputFormat formatting string or NumericPrecision option is not available.
I presume since a table can contain any data type including cells too many possibilities are opened up that TMW hasn't wanted to venture down that road.
Does seem like worthy of some design consideration for the normal cases, though, granted...
For text files, the numeric format is long g.


Show 1 older comment
dpb on 26 Oct 2020
What's the end objective file target and the data?
Perhaps rounding the data in the table first?
Walter Roberson
Walter Roberson on 26 Oct 2020
varfun() with appropriately selected input variables, with @(v) round(v,2) as the function to be applied.
madhan ravi
madhan ravi on 26 Oct 2020
Thank you dpb and sir Walter , rounding would be appropriate for my needs.

Sign in to comment.

More Answers (0)





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by