How to control the significant digits in an xlswrite

조회 수: 6 (최근 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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by