What is the default decimal precision in Matlab?

조회 수: 1 (최근 30일)
JFz
JFz 2015년 11월 13일
댓글: Star Strider 2015년 11월 13일
I am using polyfit to derive the coefficients. What is the default decimal precision in this case and for the function polyfit?
Thanks,
Jennifer
  댓글 수: 1
JFz
JFz 2015년 11월 13일
Thanks for your help. I was testing a polynomial simulation. I set the polynomial to be: y = 1+2x+3x^2+4x^3+5x^4+6x^5 and generated 1000 points. Then I used polyfit(Test1_regressor{:,1}, Test1_points{:,1}, 5); the results are: 5.993278257 5.015586479 3.987602572 3.00393415 1.999564018 1.000009082 But I expected the results should be closer to 6, 5, 4, 3, 2, 1 I wonder how to improve the precision.
Thanks. Jennifer

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

채택된 답변

Star Strider
Star Strider 2015년 11월 13일
All such calculations in MATLAB are full double-precision floating point. The decimal precision displayed in the Command Window and tooltips is set by the format function.
  댓글 수: 2
JFz
JFz 2015년 11월 13일
Thanks for your help. I was testing a polynomial simulation. I set the polynomial to be: y = 1+2x+3x^2+4x^3+5x^4+6x^5 and generated 1000 points. Then I used polyfit(Test1_regressor{:,1}, Test1_points{:,1}, 5); the results are: 5.993278257 5.015586479 3.987602572 3.00393415 1.999564018 1.000009082 But I expected the results should be closer to 6, 5, 4, 3, 2, 1 I wonder how to improve the precision.
Thanks. Jennifer
Star Strider
Star Strider 2015년 11월 13일
My pleasure.
There was a recent discussion on this very topic: Failure in a simple division. You are likely dealing with floating-point approximation error that in this instance is also likely due to the propagation of such errors through many calculations. It is inherent in binary calculations, and there is no escaping it. Some calculations that involve only integers will not have floating-point conversion error, but most calculations will.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by