What is the largest number of rows of a matrix that Matlab can handle?

19 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2020 年 7 月 28 日
編集済み: Bruno Luong 2020 年 7 月 29 日
What is the largest number of rows of a matrix that Matlab can handle? How can one know that limit in my PC?
  4 件のコメント
alpedhuez
alpedhuez 2020 年 7 月 28 日
I have posted the answer by myself above.
madhan ravi
madhan ravi 2020 年 7 月 28 日
Post it as an answer.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2020 年 7 月 28 日
2^45-1 rows is the limit for MATLAB arrays.

その他の回答 (1 件)

Steven Lord
Steven Lord 2020 年 7 月 29 日
The theoretical limit is the number returned as the second output of the computer function.
The practical limit is based on how much memory you have on your system, as it's highly unlikely you have a machine capable of creating a matrix large enough to approach the theoretical limit (unless it's a sparse tall but thin matrix.)
>> x = sparse(2^48-1, 1, 1)
x =
(281474976710655,1) 1
>> x = sparse(2^48, 1, 1)
Error using sparse
Index into matrix is too large.
In 32-bit releases of MATLAB, it was much easier to reach the theoretical limit.
  3 件のコメント
Steven Lord
Steven Lord 2020 年 7 月 29 日
>> [comptype, maxsize] = computer
comptype =
'PCWIN64'
maxsize =
281474976710655
The sparse x I created has exactly maxsize rows.
If you tried to create an array with an extremely large number of dimensions then yes, you'd consume a lot of memory with the size vector. In this example z only has two elements but it takes a little while to create.
x = [ones(1, 1e8), 2];
z = ones(x);
whos z
Bruno Luong
Bruno Luong 2020 年 7 月 29 日
編集済み: Bruno Luong 2020 年 7 月 29 日
That's interesting. I believe some older MATLAB release the limits is about 2^32 (not a lot) even for 64-bits PC. Not sure if it's a limits of conception or internal overflow bug. Glad to see TMW push this boundary further away. I might revisit my test to see if the issue I found earlier is indeed solved.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by