Out of memory when use zeros

조회 수: 1 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by