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

1 次查看(过去 30 天)
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 个评论
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