'setprecision', 24
조회 수: 13 (최근 30일)
이전 댓글 표시
Why are the two results below the same? I would like to simulate single precision with system_dependent('setprecision' , 24).
>> system_dependent('setprecision', 64)
>> 10000*sqrt(exp(pi))-48104
ans =
0.773809653510398
>> system_dependent('setprecision', 24)
>> 10000*sqrt(exp(pi))-48104
ans =
0.773809653510398
댓글 수: 0
채택된 답변
Walter Roberson
2021년 1월 25일
system_dependent('setprecision')... I seem to recall that it only ever had effect on windows and only for some of the older releases. You could find more information on Yair's undocumented-matlab site.
추가 답변 (1개)
Gaurav Garg
2021년 1월 25일
Hi,
On running the same code, and then verifying the variable precision being used, I could see that the variable precision was never changed.
You can verify the variable precision using the digits.
digits
In your case, if you need to change the precision, you can use the below piece of code -
digitsOld = digits(64);
vpa(10000*sqrt(exp(pi))-48104)
digits
digitsOld = digits(24);
vpa(10000*sqrt(exp(pi))-48104)
digits
댓글 수: 3
Walter Roberson
2021년 1월 25일
The solution with vpa needs modification to prevent the argument from being evaluated in double precision before it gets to vpa.
Q = @(v) sym(v) ;
digitsOld = digits(64);
vpa(10000*sqrt(exp(Q(pi)))-48104)
digits
digitsOld = digits(24);
vpa(10000*sqrt(exp(Q(pi)))-48104)
It would need further modifications to emulate step by step evaluation at the chosen digits the way that setting system_dependent('precision') would
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!