Is there a way to increase "realmax" in MATLAB?
You can find vpa
( variable precision arithmetic ):
R = vpa(A)
uses variable precision arithmetic (VPA) to calculate each element ofA
at leastd
decimal digits of precision, whered
is the current settingdigits
.
R = vpa(A,d)
uses equallyd
significant (nonzero) digits instead of the current settingdigits
.
Here's an example on how to use it:
>> x = vpa('10^500/20')
ans =
5.0e498
Note that:
-
the output
x
has a symbolic (sym
). Of course, you shouldn't convert it todouble
, because it will exceedrealmax
:>> double(x) ans = Inf
-
Use string input to avoid evaluating large input values like
double
. For example, it doesn't work.>> vpa(10^500/20) ans = Inf
because it
10^500
is evaluated asdouble
, givinginf
, and then used as input forvpa
.
source to share