MATLAB provides a wide range of data types (you can find detailed descriptions of MATLAB data types). The default data type is double.
However, sometimes there may be situations where the data type is not accurate enough. For example, when calculating the slope and counting down, there may often be a phenomenon where the difference is a thousand miles.
Therefore, the precision of existing data types needs to be improved. MATLAB provides a function VPA that allows you to customize data precision. For details, see product help or help.
YesDescriptionYes: When high precision is no longer required, double (data)-> double type, or other types you need.
> Help VPA
VPA variable precision arithmetic.
R = VPA (s) numerically evaluates each element of the double Matrix
S Using Variable Precision Floating Point Arithmetic with D decimal
Digit accuracy, where D is the current setting of digits.
The resulting R is a sym.
VPA (S, d) uses D digits, instead of the current setting of digits.
D is an integer or the sym representation of a number.
It is important to avoid the evaluation of an expression using double
Precision Floating Point Arithmetic before it is passed to VPA.
For example,
Phi = VPA (1 + SQRT (5)/2)
First computes a 16-digit approximation to the golden ratio, then
Converts that approximation to one with D digits, where D is the current
Setting of digits. To get full precision, use unevaluated string or
Symbolic arguments,
Phi = VPA ('(1 + SQRT (5)/2 ')
Or
S = Sym ('sqrt (5 )')
Phi = VPA (1 + S)/2 );
Additional examples:
VPA (PI, 780) shows six consecutive 9's near digit 770 in
Decimal expansion of pi.
VPA (hilb (2), 5) returns
[1.,. 50000]
[. 50000,. 33333]
See also double, digits.
Overloaded methods:
Sym/VPA
Reference page in help Browser
Doc VPA