array exceeds maximum array size preference (when summing)

3 ビュー (過去 30 日間)
Yugarshi Mondal
Yugarshi Mondal 2020 年 9 月 1 日
コメント済み: Rik 2020 年 9 月 1 日
I'm running a simulation that outputs a very long vector (of length 4 by 599901 -- only taking the fourth row).
I want to keep producing simulations of this length and add it to the previous result:
storage(kk,kkk,:) = soln(4,:) + storage(kk,kkk,:);
However I'm recieving the following error:
Requested 1x599901x599901 (2681.3GB) array exceeds maximum array size preference. Creation of arrays
greater than this limit may take a long time and cause MATLAB to become unresponsive.
I can complete the simulation and plot it, but I can't sum it in the way I've described? I think I'm bungling something. Can anyone help?

回答 (1 件)

Rik
Rik 2020 年 9 月 1 日
Use squeeze around the two terms you want to sum. The dimensions are different, so your current code attempts to use dynamic expansion, which would result in a huge matrix.
  2 件のコメント
Yugarshi Mondal
Yugarshi Mondal 2020 年 9 月 1 日
Maybe I should say kk and kkk are fixed by a loop.
Neither of the following worked:
storage(kk,kkk,:) = squeeze(soln(4,:))+squeeze(storage(kk,kkk,:));
storage(kk,kkk,:) = squeeze(soln(4,:)+storage(kk,kkk,:));
Other ideas?
Rik
Rik 2020 年 9 月 1 日
Yes: put squeeze around both terms:
storage(kk,kkk,:) = squeeze(soln(4,:)) + squeeze(storage(kk,kkk,:));

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

カテゴリ

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