【发布时间】:2017-02-22 05:39:49
【问题描述】:
我正在尝试从 Python 运行 Matlab 中运行 Simulink 模式的脚本,将变量保存为 Power.mat 并在 Python 中读取此变量。我在 Windows 上使用 Python 2.7。
我尝试使用库 hdf5storage 来读取文件:
import hdf5storage
x=hdf5storage.loadmat('Power.mat','r')
但我收到了附加错误。
可能是什么问题? 我也尝试过使用库 h5py,但我得到了同样的错误。 文件 .mat 似乎没有损坏,因为我在 Matlab 中打开它没有任何问题。
谢谢!
【问题讨论】:
-
x=hdf5storage.loadmat('Power.mat')应该可以工作,尽管下载测试它所需的包需要很长时间:) -
您是否将
Power.mat保存为 7.3 版 MAT 文件?以前的版本不是 HDF5。来自 MATLAB:type('Power.mat')将告诉您 MAT 文件版本。使用save('Power.mat', '-v7.3')指定版本。
标签: python matlab h5py hdf5storage