Matlab中数组的最大大小

时间:2022-06-29 21:26:23

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:

我尝试了零(1500 * 64),但它说“超出了程序允许的最大变量大小。”但[C,MAXSIZE] = COMPUTER返回MAXSIZE = 2.1475e + 009那么为什么它不起作用?此外,在尝试在Matlab命令行上发出这个aommand几次之后,我尝试了从零(500 * 64)到零(1500 * 64)的所有内容以找到允许的最大值,有时它返回“允许的最大可变大小”超出了计划。“对于500 * 64而且有时返回“Out of memory”。错误。可能是什么原因?这是memory命令返回的内容:

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)

最大可能数组:486 MB(5.094e + 008字节)*可用于所有阵列的内存:1436 MB(1.506e + 009字节)** MATLAB使用的内存:353 MB(3.697e + 008字节)物理内存(RAM) :3070 MB(3.219e + 009字节)

  • Limited by contiguous virtual address space available. ** Limited by virtual address space available.
  • 受可用的连续虚拟地址空间限制。 **受虚拟地址空间的限制。

Output of [u,s] = memory

输出[u,s] =记忆

[u, s] = memory

[u,s] =记忆

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?

如何根据元素的nuber和占用的总字节数来计算此信息的允许最大大小?

2 个解决方案

#1


3  

The command

 x = zeros(1500*64);

attempts to create a square matrix of double precision zeros, 96000 elements per side, requiring 73 gigabytes.

尝试创建双精度零的方阵,每边96000个元素,需要73千兆字节。

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.

它创建了一个1500×64的双精度零阵列,需要0.8兆字节的内存。

#2


1  

When I google for that error message, first hit is a descriptive help page from MathWorks, the developer of MatLab:

当我谷歌搜索该错误消息时,首先点击是MathWorks的开发人员MathWorks的描述性帮助页面:

According to that, you should use the computer command, not memory, to learn the maximum matrix size supported by your edition of MatLab.

根据这一点,您应该使用计算机命令而不是内存来学习您的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".

对于“Out of Memory”错误,取内存报告的“Maximum possible array:486 MB(5.094e + 008 bytes)”,除以数组元素的大小(双精度实数值为8个字节,是MatLab默认使用的)。它是如此之低的原因是由于地址空间碎片,这是内存命令在谈到“受连续地址空间限制”时告诉你的。

#1


3  

The command

 x = zeros(1500*64);

attempts to create a square matrix of double precision zeros, 96000 elements per side, requiring 73 gigabytes.

尝试创建双精度零的方阵,每边96000个元素,需要73千兆字节。

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.

它创建了一个1500×64的双精度零阵列,需要0.8兆字节的内存。

#2


1  

When I google for that error message, first hit is a descriptive help page from MathWorks, the developer of MatLab:

当我谷歌搜索该错误消息时,首先点击是MathWorks的开发人员MathWorks的描述性帮助页面:

According to that, you should use the computer command, not memory, to learn the maximum matrix size supported by your edition of MatLab.

根据这一点,您应该使用计算机命令而不是内存来学习您的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".

对于“Out of Memory”错误,取内存报告的“Maximum possible array:486 MB(5.094e + 008 bytes)”,除以数组元素的大小(双精度实数值为8个字节,是MatLab默认使用的)。它是如此之低的原因是由于地址空间碎片,这是内存命令在谈到“受连续地址空间限制”时告诉你的。