Out of Memory error when removing columns of a big matrix .
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2020년 1월 24일
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.
답변 (1개)
James Tursa
2020년 1월 24일
편집: James Tursa
2020년 1월 24일
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:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!