How to control the significant digits in an xlswrite

1 回表示 (過去 30 日間)
Douglas Anderson
Douglas Anderson 2015 年 8 月 10 日
回答済み: Walter Roberson 2015 年 8 月 10 日
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

採用された回答

Walter Roberson
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 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by