【问题标题】:How to create a very large sparse identity matrix in Matlab?如何在 Matlab 中创建一个非常大的稀疏单位矩阵?
【发布时间】:2016-03-11 00:53:59
【问题描述】:

我正在尝试使用代码在 Matlab 中创建一个 75000*75000 单位矩阵:

sparse(eye(75000))

我收到以下错误:

Requested 75000x75000 (41.9GB) array exceeds maximum array size preference. Creation of arrays
greater than this limit may take a long time and cause MATLAB to become unresponsive. See array
size limit or preference panel for more information.

我知道错误的原因,但是如何在 Matlab 中创建这样一个稀疏矩阵?

【问题讨论】:

  • speye 是文档中的third result...
  • 谢谢。如果你提供,我会接受你的回答。

标签: matlab matrix


【解决方案1】:
sparse(eye(75000));

需要将eye(75000) 存储在内存中。您想使用speye 来避免中间步骤:

speye(75000);

我还建议阅读Sparse Matrix Creation 的文档。

【讨论】:

    猜你喜欢
    • 2023-03-05
    • 2014-09-07
    • 2015-04-25
    • 2016-11-22
    • 2012-09-21
    • 2014-06-16
    • 2019-05-06
    • 2011-03-11
    • 1970-01-01
    相关资源
    最近更新 更多