Out of memory when use zeros

3 ビュー (過去 30 日間)
alize beemiel
alize beemiel 2020 年 11 月 11 日
コメント済み: Image Analyst 2020 年 11 月 12 日
hi
i have
Out of memory. Type HELP MEMORY for your options.
hen i want to creat a matrix KG
KG=zeros(3*NNOD,3*NNOD);
NNOD= 2000
i use matlab 2014b in windows32
there is another way to create matrix KG or built KG ithout initialise it to zeros
  4 件のコメント
Steven Lord
Steven Lord 2020 年 11 月 11 日
In addition to what others have said, you indicated:
i use matlab 2014b in windows32
A 32-bit version of MATLAB on 32-bit Windows is severely limited in how much memory it can access. If you can switch to a 64-bit version of MATLAB on a 64-bit version of Windows, that may help you out.
alize beemiel
alize beemiel 2020 年 11 月 12 日
thank s for your advice
waiting for switch to 64 bit
i used
KG = zeros(3*NNOD, 3*NNOD, 'single'); for now
and its work
thank you

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

回答 (1 件)

Image Analyst
Image Analyst 2020 年 11 月 11 日
How are you going to use this array? Are you just going to see if the values are 0 or 1? If so, you can use a logical array and use 8 times less memory:
NNOD = 2000
KG = false(3*NNOD, 3*NNOD); % Using false instead of zeros to create a logical matrix.
Alternatively, if it needs to be floating point, because it has values other than 0 and 1, you can cast it to single instead of double. This will cut the memory used by half:
NNOD = 2000
KG = zeros(3*NNOD, 3*NNOD, 'single'); % Using 'single' to make array single precision instead of double precision.
You can also cast it to int32, int16, uint8, or other types depending on how you're going to use it and what you plan on putting into the matrix.
  5 件のコメント
James Tursa
James Tursa 2020 年 11 月 12 日
... which is why I wish we could vote for comments.
Image Analyst
Image Analyst 2020 年 11 月 12 日
David, I didn't see anyone mentioning logical so I added that. And then I saw that no one had given actual code for 'single', which users usually like so they can click the copy button and don't need to look up in the documentation to figure it out, so I added that code for the user's convenience. I suggest you move your comment down to the official "Answers section" since your comment seems more like an actual answer (and a very good one!) than a comment asking the poster for clarification. We're supposed to comment on the poster's original post when we need to ask questions about it to get them to clarify it or add missing info or files, but otherwise put answers further below in the Answers section.

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

カテゴリ

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