maximum size for an array in Matlab
I tried zeros(1500*64) but it says "Maximum variable size allowed by the program is exceeded."
But [C,MAXSIZE] = COMPUTER returns MAXSIZE = 2.1475e+009
So why isn't it working? Also, after trying to issue this aommand on the Matlab command line a few times, I tried everything from zeroes(500*64) to zeros(1500*64) to find the maximum allowed, and sometimes it returned "Maximum variable size allowed by the program is exceeded." for 500*64 and sometimes returned "Out of memory." error. What could be the reason for that? This is what the memory command returns:
Maximum possible array: 486 MB (5.094e+008 bytes) * Memory available for all arrays: 1436 MB (1.506e+009 bytes) ** Memory used by MATLAB: 353 MB (3.697e+008 bytes) Physical Memory (RAM): 3070 MB (3.219e+009 bytes)
Output of [u,s] = memory
[u, s] = memory
u =
MaxPossibleArrayBytes: 509411328
MemAvailableAllArrays: 1.5057e+009
MemUsedMATLAB: 369819648
s =
VirtualAddressSpace: [1x1 struct]
SystemMemory: [1x1 struct]
PhysicalMemory: [1x1 struct]
How do I calculate my allowed maximum size from this information, both in terms of nuber of elements and total bytes occupied?
The command
x = zeros(1500*64);
attempts to create a square matrix of double precision zeros, 96000 elements per side, requiring 73 gigabytes.
I suspect you want to use
x = zeros(1500,64);
which creates a 1500-by-64 array of double precision zeros, requiring 0.8 megabytes of memory.
When I google for that error message, first hit is a descriptive help page from MathWorks, the developer of MatLab:
According to that, you should use the computer
command, not memory
, to learn the maximum matrix size supported by your edition of MatLab.
For the "Out of Memory" error, take the "Maximum possible array: 486 MB (5.094e+008 bytes)" reported by memory
, and divide by the size of an array element (8 bytes for double-precision real values, which is what MatLab uses by default). The reason it's so low is due to address space fragmentation, which is what the memory
command is telling you when it talks about "Limited by contiguous address space".
上一篇: 超过程序允许的最大可变大小
下一篇: Matlab中数组的最大尺寸