Is there a command to compress a matrix in memory in MATLAB?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 15 Apr 2010
Commentato: Steven Lord
il 4 Ago 2018
I would like to be able to compress a matrix in memory, so that I can do calculations on larger matrices.
Risposta accettata
MathWorks Support Team
il 15 Apr 2010
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 Commenti
Steven Lord
il 4 Ago 2018
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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!