How does matlab improve matrix storage accuracy
11 次查看(过去 30 天)
显示 更早的评论
Hi,everyone,I encountered a problem. The number in a matrix is too large and exceeds the storage space of 16 bits. I want to expand the storage space of the matrix. It is best if it can be expanded to 200 bits. I know that the vpa function can help us perform high-precision simple operations, but storing high-precision data in a matrix will store double type data by default. Is there any way to expand the number stored in the matrix to 200 digits? The amount of calculation is not a problem.

this is a 10 order martix.
i need calculate 20 order martix.the maximum date of the 20 order martix can reach 10 to the 200th power
0 个评论
回答(1 个)
Walter Roberson
2020-8-28
storing high-precision data in a matrix will store double type data by default.
The data type of an array is determined by the first value you store to the array.
If you initialize the array
M = zeros(10,10);
then that creates M as a double precision array, and if you attempt to store a symbolic number into part of M, then the symbolic number will be converted to double precision.
So instead initialize the array as symbolic:
M = zeros(10, 10, 'sym');
After which, for example,
M(1,1) = vpa(exp(sym(pi)),200);
Note that the full 200 digits will not be displayed, but you can tell with calculations that they are stored internally.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!