How to control the significant digits in an xlswrite
6 次查看(过去 30 天)
显示 更早的评论
Hello!
I got some very good answers to a previous post about Excel xlswrite and the MATLAB COM API, controlling the number of columns. That made the write come out not "squished", but now I've got a zillion decimal digits! (well, nine really, but only three are meaningful). Any suggestions on this?
This looks like a great utility, but I haven't figured out where it is documented.
Thanks again.
Doug
0 个评论
采纳的回答
Walter Roberson
2015-8-10
If you are not using xlswrite() in 'basic' mode then numeric values are written in binary so the number of decimals cannot be controlled by xlswrite(). The work-around is to adjust the number of decimal places before you call xlswrite().
Caution: the only three decimal digit fractions that can be exactly represented in binary are .0, .125, .25, .375, .5, .625, .75, .875 . You can use round(Value*1000)/1000 to approximate 3 decimal places, but the approximations will not be exact except for the 8 values I list.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!