Precision number throughout scripts and functions.

조회 수: 5 (최근 30일)
daniel adams
daniel adams 2021년 11월 15일
댓글: Rik 2021년 11월 15일
I have a script that calls many functions, when I run the script I want matlab to use a specific value of precision throughout. I have seen the documentation https://uk.mathworks.com/help/symbolic/increase-precision-of-numeric-calculations.html but this seems to just increase the precision for one single calculation?
Is there a way to set the precision to run throughout my entire code?
  댓글 수: 1
Rik
Rik 2021년 11월 15일
It sets the precision for the uses of that variable, just like setting the data type to single would do.
You need to make sure that all calculations are performed with the vpa-created variables.

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

답변 (1개)

Chunru
Chunru 2021년 11월 15일
You can use "format" command to specify a format such as short, long, shortE, shortG. "doc format" for more information.
If you do want to have complete control of the display format, you need to use "fprintf" command.
  댓글 수: 3
daniel adams
daniel adams 2021년 11월 15일
In fact "Numeric formats affect only how numbers appear in Command Window output, not how MATLAB® computes or saves them"
Rik
Rik 2021년 11월 15일
format (or fprintf) will only affect the display, not the precision. You are on the right track with vpa if you need more than what double can provide.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by