打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
solem's vision blog: Reading and writing .mat files with Python

Reading and writing .mat files with Python

If you have some old data, or find some interesting data set online,stored in Matlab's .mat file format it is possible to read this usingthe scipy.io module in SciPy. This is how to do it.

data = scipy.io.loadmat('test.mat')

"data"now contains a dictionary with keys corresponding to the variable namessaved in the original .mat file. The variables are in array format.Saving to .mat files is equally simple. Just create a dictionary withall variables you want to save and use savemat().

data = {}
data['x'] = x
scipy.io.savemat('test.mat',data)

This saves the array x so that it has the name "x" when read into Matlab. More information on scipy.io can be found in the online documentation.
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
python读取.mat数据之scipy.io&h5py
scipy.io.loadmat && imsave
C++ Excel Library to read/write xls/xlsx files
Writing In-Memory Applications
3段极简代码带你入门Python科学计算库SciPy
每天一句口语练习:I can't read your writing
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服