how resolve Get out of memory error in Matlab?

2 次查看(过去 30 天)
I have matlabR2013a on a 4GiG RAM system and window7. I have the code below:
c = x'*x/(n-d);
x is a 28944*30 double matrix and n and d are 1*1 matrix(a number). when I run this line of code I got error: Out of memory. Type HELP MEMORY for your options.
how can I fix this error? I increase the amount of virtual heap memory but no thing changed!
thanks for your help.

回答(1 个)

Guillaume
Guillaume 2014-8-26
If Windows 7 is the 32 bit version, then Matlab can't use more than 2 GB (3GB if you mess about with the OS). If you're using the 32 bit version of Matlab on a 64 bit OS, then you're limited to under 4 GB.
However, the memory footprint of the arrays you're listing is minimal. On my machine x is about 6 MB. You'll need another 6MB free to temporarily store the transpose and possibly 6MB for x/(n-d), but it shouldn't tax your system.
Check how much memory you have free with
memory
In particular, Maximum possible array tells you what is the max. size of a single array.
Check how much the existing variables use with
whos
Clear the variables you don't need.
FInally have a look at this page (and of course do type HELP MEMORY as instructed).
  5 个评论
Guillaume
Guillaume 2014-8-27
No, it's not a restriction of matlab. If you do want to create a 28944 x 28944 matrix, it will use over 6GB of memory regardless of the program.
You could halve the memory usage by switching to single instead of double but it's still more memory than you have.
If you do want to calculate an array of that size, your only option is to calculate part of it, save it to disk, calculate another part, save it to disk, and so on.

请先登录,再进行评论。

类别

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