【问题标题】:Getting a matlab code's results on python在 python 中获取 matlab 代码结果
【发布时间】:2012-06-28 11:35:57
【问题描述】:

我在 matlab 中有代码,我想在 python 代码中使用其结果(作为矩阵或 .dat 文件)。谁能告诉我这是怎么做到的?

【问题讨论】:

    标签: python matlab file-io


    【解决方案1】:

    NumPy 和 SciPy 可以直接使用 scipy.io.loadmatscipy.io.savemat 读写 MATLAB .mat 文件。

    【讨论】:

    • 我不这么认为。根据loadmat 文档“我们没有实现 HDF5 / 7.3 接口”。所以我认为不是 - 你指出这一点很好。
    • 有读取HDF5的Python模块,例如this one
    【解决方案2】:

    .dat 文件只是一个文本文件:

    fid = fopen('outputFile.dat', 'wt');
    fprintf(fid, your_data_in_string_format);
    fclose(fid);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多