对于matlabv7.3,您可以使用hdf5storage,它需要h5py,在这里下载文件,提取,然后在命令提示符下输入:python setup.py install。
https://pypi.python.org/pypi/hdf5storageimport h5py
import hdf5storage
import numpy as np
matfiledata = {} # make a dictionary to store the MAT data in
matfiledata[u'variable1'] = np.zeros(100) # *** u prefix for variable name = unicode format, no issues thru Python 3.5; advise keeping u prefix indicator format based on feedback despite docs ***
matfiledata[u'variable2'] = np.ones(300)
hdf5storage.write(matfiledata, '.', 'example.mat', matlab_compatible=True)
如果MATLAB不能一次加载整个程序,我想你必须将它保存在不同的变量matfiledata[u'chunk1'] matfiledata[u'chunk2'] matfiledata[u'chunk3']等
然后在MATLAB中,如果你把每个块都保存为一个变量
^{pr2}$
等等
hdf5存储.savemat有一个参数,允许将来将文件正确地读入Python,因此值得检查,并遵循scipy.io.loadmat公司格式。。。如果从MATLAB中保存数据以便于导入回Python,则可以执行以下操作:MATLAB
save('example.mat','-v7.3')
Python
matdata = hdf5storage.loadmat('example.mat')
这将作为一个字典加载回Python中,然后可以将其转换为所需的任何数据类型。在