maximum array size issue while a mass calculation
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Steven Lord
on 3 Oct 2016
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 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!