python读mat7.3_在python中创建v7.3的.mat文件

对于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中,然后可以将其转换为所需的任何数据类型。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值