MATLAB中的矩阵大小限制

9

有两个限制:(1)数组中允许的元素数量的最大值,是一个硬性限制,和(2)单个数组可用的字节数。这些数字非常不同。请参见其他问题和此答案的完整细节。 - chappjc
2个回答

6

在Matlab中,内存仅受操作系统提供的内存(包括虚拟内存)限制。矩阵被作为连续空间存储在内存中,因此如果您有一个需要占用8GB内存的矩阵,则需要在内存中有一块8GB大小的连续内存可用。

您可以使用memory命令提供有关可用内存的详细统计信息,包括单个矩阵可用的连续内存量。例如:

> memory

Maximum possible array:           677 MB (7.101e+008 bytes) *
Memory available for all arrays: 1601 MB (1.679e+009 bytes) **
Memory used by MATLAB:            446 MB (4.681e+008 bytes)
Physical Memory (RAM):           3327 MB (3.489e+009 bytes)

  *  Limited by contiguous virtual address space available.
  ** Limited by virtual address space available.

要计算 最大可能数组 值对应的数组大小,只需将其除以每个数组元素所需的字节数即可。参考memory文档:

Maximum Possible Array

Maximum Possible Array is the size of the largest contiguous free memory block. As such, it is an upper bound on the largest single array MATLAB can create at this time.

MATLAB derives this number from the smaller of the following two values:

* The largest contiguous memory block found in the MATLAB virtual address space
* The total available system memory

To see how many array elements this number represents, divide by the number of bytes in the array class. For example, for a double array, divide by 8. The actual number of elements MATLAB can create is always fewer than this number.

Mathworks也提供了详细的文档,介绍如何避免内存不足错误,文档链接在这里

1

是的,您受到计算机可用RAM数量的限制。您可以使用MATLAB命令来检查此限制。

feature( 'memstats' )

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接