필터 지우기
필터 지우기

How to check the accuracy of estimation

조회 수: 3 (최근 30일)
Lorenne
Lorenne 2018년 5월 7일
편집: Stephen23 2018년 5월 7일
Using the approximated volume i have 0.51666667 and the true volume is 0.52359878 , the error is 0. 00 693211 so it will be accurate by 2 decimal places. How do i only print the values if only the decimal place has increased by 1? I used floor(-log10(error)) but it counted incorrectly as the error gets smaller. For points of 168, the zeros in front should be 5, but it calculated to be 6 . May i know what is wrong?
  댓글 수: 1
Stephen23
Stephen23 2018년 5월 7일
편집: Stephen23 2018년 5월 7일
"For points of 168, the zeros in front should be 5, but it calculated to be 6 . May i know what is wrong?"
Look more closely at the error value and you will find that it actually has 6 leading zeros. Try fprintf to thirty significant figures, or download and use James Tursa's excellent num2strexact.
Welcome to the world of floating point numbers! Note that how floating point numbers are displayed is not the same thing as what value is actually stored in memory.

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

답변 (1개)

Walter Roberson
Walter Roberson 2018년 5월 7일
Observe:
>> fprintf('%.8f\n', 0.000000999)
0.00000100
Actual number of leading 0: 6. The 5 visible are due to rounding for presentation.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by