Increase limit on Matrix size

62 views (last 30 days)
Rehan Rehan
Rehan Rehan on 5 Feb 2016
Commented: Steven Lord on 23 Mar 2019
Hi,
Presently matlab has put a limit of 10k on max array dimension. Matlab is not allowing me to use more than that. How can we increase it?
Thanks
  2 Comments
Walter Roberson
Walter Roberson on 5 Feb 2016
Do you mean that you want ndims() of the array to be greater than 10000, or do you mean that you want one particular dimension of an array to be that large?
Did you accidentally use
A = zeros(1:10000)
instead of
A = zeros(1,10000)
Walter Roberson
Walter Roberson on 5 Feb 2016
I just created an array with over 100 million dimensions.

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 5 Feb 2016
There's a limit on the number of elements an array can have. With the 64-bit version of MATLAB that's a theoretical limit since you'd need a machine with hundreds of terabytes of memory to create one such array. But that limit is much, much more than 10000.
The old Student Edition of MATLAB that was distributed by Prentice-Hall (not the currently available Student Version from MathWorks) had a limitation of 128-by-128 on matrix size, but I believe that hasn't been for sale except maybe on eBay as a novelty for 15 years or so.
[I have a copy of the Student Edition version 5 for the Mac on my bookshelf, and to put its age into perspective the system requirements list System 7.1 or later (System 7.5 recommended) and the Notebook interface requires Microsoft Word 6.0. The manual inside is copyrighted 1997.]
You're going to need to clarify which version of MATLAB you're using and provide more details about what you're doing and what MATLAB is telling you before we can figure out where this limitation you've encountered is coming from.
  6 Comments
Ginaris Ajeng
Ginaris Ajeng on 19 Jan 2017
So, can I conclude that about this size of array it is dependent to the matlab version and size of our RAM?
Walter Roberson
Walter Roberson on 19 Jan 2017
The limits are:
  • Prentice Hall version of MATLAB (book): 128 x 128
  • 32 bit MATLAB: maximum array size is 2^31-1 bytes. This is an architectural limitation for compatibility with 32 bit architectures that reserve the top bit for privileged memory accesses (as SGI systems used to do.) The limit of 2^31-1 bytes is not strictly required for 32 bit MS Windows systems that have the appropriate XME hardware feature, so Mathworks could have pushed the limit up a bit
  • 32 bit MATLAB: you run into difficulty creating arrays with more than about 2^27 dimensions. You might have been able to do 2^28-1 dimensions, perhaps; I did not check that. The header on the array has to store the size of each dimension, and eventually the amount of memory needed to do so reaches 2^31 bytes even though the amount of storage in the array might be small (think many many many 1's in the dimensions.)
  • 64 bit MATLAB: no array can occupy more than 2^48-1 bytes, because all current versions of the x64 architecture use only 48 address pins.
  • 64 bit MATLAB: the 2^48-1 byte limitation would apply to the dimension header as well, so you probably could not go beyond 2^45-1 dimensions.

Sign in to comment.

More Answers (1)

Nicole Rappaport
Nicole Rappaport on 23 Mar 2019
my program needs to use a matrix of dimension 100,000 x 100,000 x 100,000. The responses I read above are too sophisticated for me. Could someone tell me a simple way to allow this? By the way, I am talking about MATLAB.
Thanks in advance,
Nicole
  3 Comments
Walter Roberson
Walter Roberson on 23 Mar 2019
It is not possible to do that unless the array is sparse.
Even if your array was uint8 or logical, it would require 10^15 bytes of memory, which exceeds 2^49 bytes, but the x64 architecture has a limit of 2^48 bytes on all known implementations.
The largest publicly known computer memory in the world is an HP server with 160 terabytes of memory https://www.forbes.com/sites/aarontilley/2017/05/16/hpe-160-terabytes-memory/ . Even with uint8 values, the array you want to create is more than 5 times larger than that. You would need 6 of those Largest Computer in the World to fit your array. And if your array was double precision, you would need 46 of them.
Steven Lord
Steven Lord on 23 Mar 2019
To put it another way, Wikipedia states that 'as of March 2014 "the Library [U.S. Library of Congress] has collected about 525 terabytes of web archive data" and that it adds about 5 terabytes per month ("one terabyte = 1,024 gigabytes").' At that rate, the Library will have 1 petabyte (1000 terabytes) of web archive data:
>> startDate = datetime('March 1, 2014');
>> terabytesToAdd = 1000-525;
>> monthsToAdd = terabytesToAdd/5;
>> timeReaching1PB = startDate + calmonths(monthsToAdd)
timeReaching1PB =
datetime
01-Feb-2022
a couple years from now.

Sign in to comment.

Categories

Find more on Particle & Nuclear Physics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!