feature('setprecision') in matlab 2022

조회 수: 26 (최근 30일)
Elsiddig Elsiddig
Elsiddig Elsiddig 2023년 3월 27일
편집: Venkat Siddarth 2025년 5월 13일
Hello, currently I have matlab 2022a. It seems the command
feature('setprecision')
does not work in it. The function feature itself works but does can not find setprecision. It shows the following error message:
Error using feature
Feature precision not found
Is there a way around this?
Thank you.

답변 (1개)

Venkat Siddarth
Venkat Siddarth 2023년 4월 4일
편집: Venkat Siddarth 2025년 5월 13일
Hi Elsiddig
I understand that you are facing issues in using feature function with setprecison parameter.
The feature('setprecision') command is used to set the precision of the numeric calculations in MATLAB. However, it is an undocumented command and shouldn't be used.
One possible workaround, is to use the vpa() function to perform calculations with a higher precision. vpa() stands for variable precision arithmetic and allows you to specify the desired number of digits for your calculations.
For example, you can use the following code to perform a calculation with 100 digits of precision:
digits(100) %Digits function is used to set the precison used by vpa, by default it is 32 bits
a = vpa(pi)
a = 
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068
%But if you want to explicitly change the precison of specific variables you can
%do it as follows and it wont effect the value of "digits".
b = vpa(exp(1),10)
b = 
2.718281828
%Note: Arithmetic operation happen according to the value of digits
c=a*b
c = 
8.539734222673566611300185395393428880590006981651537285035011588320340680535960171405242699594003394
I hope this resolves the issue
Venkat Siddarth V.
[EDIT: Updated text to clarify about feature function]
  댓글 수: 2
Stephen23
Stephen23 2023년 4월 4일
편집: Stephen23 2023년 4월 4일
"The feature('setprecision') command is used to set the precision of the numeric calculations in MATLAB. "
The FEATURE function has never been documented. But now we have an official statement from TMW staff, what it is used for. Can you also provide a link to some documentation for this function?
Oliver Jaehrig
Oliver Jaehrig 2025년 5월 13일
@Stephen23 As you mentioned, this is an undocumented command and should not be used by end users.
Since it is not documented, there is no link existing for a published documentation.
In this thread the solution is to use a documented command (vpa).

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

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by