栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Python来自MATLAB .fig文件的数据?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Python来自MATLAB .fig文件的数据?

.fig文件是.mat文件(包含结构),请参见 http://undocumentedmatlab.com/blog/fig-files-
format/

作为状态的参考,仅在v7.1之前支持结构:http :
//www.scipy.org/Cookbook/Reading_mat_files

因此,在MATLAB中,我使用-v7保存:

plot([1 2],[3 4])hgsave(gcf,'c','-v7');

然后在Python 2.6.4中,我使用:

>>> from scipy.io import loadmat>>> x = loadmat('c.fig')>>> x{'hgS_070000': array([[<scipy.io.matlab.mio5.mat_struct object at 0x1500e70>]], dtype=object), '__version__': '1.0', '__header__': 'MATLAB 5.0 MAT-file, Platform: MACI64, Created on: Fri Nov 18 12:02:31 2011', '__globals__': []}>>> x['hgS_070000'][0,0].__dict__{'handle': array([[1]], dtype=uint8), 'children': array([[<scipy.io.matlab.mio5.mat_struct object at 0x1516030>]], dtype=object), '_fieldnames': ['type', 'handle', 'properties', 'children', 'special'], 'type': array([u'figure'], dtype='<U6'), 'properties': array([[<scipy.io.matlab.mio5.mat_struct object at 0x1500fb0>]], dtype=object), 'special': array([], shape=(1, 0), dtype=float64)}

.__dict__
以前在哪里查看如何遍历结构。例如
XData
YData
我可以使用:

>>> x['hgS_070000'][0,0].children[0,0].children[0,0].properties[0,0].XDataarray([[1, 2]], dtype=uint8)>>> x['hgS_070000'][0,0].children[0,0].children[0,0].properties[0,0].YDataarray([[3, 4]], dtype=uint8)

证明我

plot([1 2],[3 4])
在MATLAB中使用过(孩子是轴,孙子是线系列)。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/634269.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号