Out of Memory error when removing columns of a big matrix .

1 vue (au cours des 30 derniers jours)
Ozge Ozcakir
Ozge Ozcakir le 24 Jan 2020
Modifié(e) : James Tursa le 24 Jan 2020
Hello,
I have constructed a big matrix A in MATLAB ( 120000 x 120000) without any issue. However, I am getting out-of-memory error when i try to remove few columns of this matrix using A(:,1:10)=[]. I am guessing, MATLAB is creating a temporary matrix while doing this operation and thats why i am getting an error.
Is there a way to overcome this issue?
  1 commentaire
Walter Roberson
Walter Roberson le 24 Jan 2020
Yes, MATLAB does create a temporary matrix for this purpose.
I do not know if there is any alternative, even using mex; I do not know if there is a realloc() equivalent that can give back trailing memory.
It would possibly be easier if you were to fill in the shortened matrix with 0 or NaN so that the columns were compacted but the array stayed the same size.

Connectez-vous pour commenter.

Réponses (1)

James Tursa
James Tursa le 24 Jan 2020
Modifié(e) : James Tursa le 24 Jan 2020
What are you doing with the matrix A downstream in your code? Even if the column removal worked, seems like you still might have problems downstream when using A in a calculation which would create another large variable.
There is no easy mex solution for this either, since you can't set the data pointer of a variable to point to the interior of an allocated memory block legally. The only workaround I can think of is this FEX mex submission which uses unofficial hacks to point at the interior of a variable without a data copy:

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by