【问题标题】:Matlab cannot import a matrixmarket fileMatlab 无法导入矩阵市场文件
【发布时间】:2022-02-08 18:00:23
【问题描述】:

我一直在 Matlab 上使用mmread 来导入 MatrixMarket 文件。 但它不适用于 .mtx 文件 here,尽管它适用于 .mtx 文件 here。错误消息是:在调用期间未分配输出参数“A”(可能还有其他参数) “mmread”。

命令:

temp=mmread('GSM2396856_dc_3hr.mtx.txt');

【问题讨论】:

  • 请告诉我们你是怎么打电话给mmread的。
  • 刚刚添加了代码
  • 该错误表明 mmread 中存在错误(或 mtx 文件中的错误和 mmread 中的错误处理不佳)。我会尝试在分配了Ammread 中的所有位置设置断点,这样您就可以检查是否至少访问了其中一个位置,看看那里出了什么问题。

标签: matlab


【解决方案1】:

函数 mmread 仅支持 'field' 为 'real, complex and pattern'。因此,如果该字段指示为整数,我会得到与您相同的错误报告。我建议您将其更改为真实的。而且我认为这是工具开发人员应该添加到功能中的东西。

【讨论】:

    【解决方案2】:

    函数 mmread 不支持整数字段。您可以通过将以下内容添加到 mmread 来对其进行修改。

    if  ( strcmp(field,'integer') )               % integer valued entries:
    
    [T,count] = fscanf(mmfile,'%i',3);
    T = [T; fscanf(mmfile,'%i')];
    if ( size(T) ~= 3*entries )
       message = ...
       str2mat('Data file does not contain expected amount of data.',...
               'Check that number of data lines matches nonzero count.');
       disp(message);
       error('Invalid data.');
    end
    T = reshape(T,3,entries)';
    A = sparse(T(:,1), T(:,2), T(:,3), rows , cols);
    

    elseif ( strcmp(field,'real') ) % 实值条目: ....................

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-30
      • 1970-01-01
      • 2022-01-05
      • 2014-11-01
      • 2015-02-16
      相关资源
      最近更新 更多