필터 지우기
필터 지우기

Numerical difference between Matlab result and MS Excel result

조회 수: 2 (최근 30일)
Zhi Hao
Zhi Hao 2011년 6월 27일
Hi,
I am interested in obtaining exact output between matlab calculation and MS excel computation.
Here's an example. In excel, key in this: 123456789123456789
Result in MS excel: 123456789123456000
In matlab, key in this: 123456789123456789
Result in Matlab: 123456789123457000
Can anyone advise me how can I eliminate the difference between the two platforms?
zhi hao

답변 (1개)

Doug Eastman
Doug Eastman 2011년 6월 27일
When I type '123456789123456789' in a numeric field in Excel, I get 123456789123456000. The issue is due to floating point data types, discussed extensively (for example see Cleve's Corner. If you type
eps(123456789123456789)
You can see the accuracy around that number for a double data type is 16, so in MATLAB the value represented is 123456789123456780.
The only way I see to use the full number is Excel is to format the cell as text.
In MATLAB there are a couple of options, you could use VPA in the Symbolic Math Toolbox, or you could use the 64-bit integer data type, try:
uint64(123456789123456789)
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 6월 27일
Note: until quite recent releases, uint64(123456789123456789) would construct the double precision number corresponding to 123456789123456789 and then would convert that number to uint64. There was no direct way in those releases to get a uint64 number that needed more than 53 bits.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by