Is there a command to compress a matrix in memory in MATLAB?

13 次查看(过去 30 天)
I would like to be able to compress a matrix in memory, so that I can do calculations on larger matrices.

采纳的回答

MathWorks Support Team
The ability to compress a matrix that is stored in memory is not available in MATLAB. The numerical data that is usually stored in the matrices is already stored in an efficient format.
A compression algorithm thus would not achieve any meaningful compression rates unless a lot of the elements are the equal. Compression algorithms are very time consuming and would slow down calculations.
To work around this issue, if your matrix contains a large amount of elements that are equal to cero, use the function SPARSE to create a sparse matrix that will store the matrix in a more memory-efficient way. Furthermore, and depending on your application, using a data type will less precision will also reduce the memory requirements of a large matrix.
  3 个评论
dpb
dpb 2018-8-4
It would still take having the original data to compress, wouldn't it?
Steven Lord
Steven Lord 2018-8-4
Depending on the structure of your data and what you want to do with it, there may be other alternatives. Some functions, like gmres or eigs, allow you to specify a function handle that computes some function of your matrix rather than providing the matrix itself. If you can perform the operations required to evaluate that function without explicitly creating the matrix, that may help you operate on larger data than you would otherwise be able to use.
Another option is to use a datastore to create a tall array to operate on data that cannot fit in memory.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2006a

Community Treasure Hunt

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

Start Hunting!

Translated by