필터 지우기
필터 지우기

How to quote variables whose names are in order in a for loop?

조회 수: 1 (최근 30일)
Jason Yang
Jason Yang 2021년 3월 29일
댓글: Steven Lord 2021년 4월 27일
Hi! I want to store a 6D tensor A which is so large that I meet the 'out of memory' error. So I want to store it by parts. i.e. store A by sub-tensors A1,A2,...An. I know I can create variables whose name are in order by eval(). For example, I can create x1,...,x10 by:
VarNum = 10;
vars = [];
for i = 1:VarNum
eval([['x',num2str(i-1)],'=','i',';']);
end
But I don't know how to quote x1,...x10 in a for-loop when I don't store x1,...x10 into an array or cell which contains too large space and I will encounter 'out of memory' error. Can anyone help me? Thank you!
  댓글 수: 7
Jason Yang
Jason Yang 2021년 4월 27일
@Walter Roberson That helps a lot! My question is solved. Thank you very much!
Steven Lord
Steven Lord 2021년 4월 27일
An analogy that might make this clear is that of a hardcover version of the combined Lord of the Rings series of books. That volume requires a certain width of shelf space to store, and all that space has to be on the same shelf.
If you were to split the series into three volumes they would take up (basically) the same total width, but you could put the first volume on one shelf and the other two on the next shelf down. Though if you misplace volume 2 it could take you a while to find it when you want to read from it.
The combined hardcover is a double array, the three volumes are a cell array each cell of which contains part of the larger double array.

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2021년 4월 7일
See if some of the tools in MATLAB for working with data that is too large to fit in memory on one machine all at once will satisfy your needs.

카테고리

Help CenterFile Exchange에서 Model Upgrades에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by