maximum array size issue while a mass calculation
3 次查看(过去 30 天)
显示 更早的评论
For a large amount of calculation, I need to make a binary matrix of 1350 by 3000000. all elements are zero or one. i just tried to make the same size of zero matrix first, but it says the following.
Error using zeros Requested 3000000x1350 (30.2GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
How can I solve this problem? is there any way that I can reduce the memory the matrix takes? or, can I increase the maximum array size preference?
0 个评论
回答(1 个)
Steven Lord
2016-10-3
You could try:
x = false(3000000, 1350);
That will consume less memory than creating a double array of that same size, though it will still require a large chunk of memory. If you expect the array to contain only a few nonzero elements, instead I recommend creating a sparse array using either:
x = sparse(3000000, 1350, false);
or the spalloc function (if you know roughly how many nonzero elements it will contain.)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!