300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > python读取 .mat 文件(matlab文件)

python读取 .mat 文件(matlab文件)

时间:2020-04-03 16:34:03

相关推荐

python读取 .mat 文件(matlab文件)

python读取 .mat 文件(matlab文件)和 scipy库包的使用(4—1224)

一、python调勇scipy库读取.mat文件1、使用例子12、 使用例子2二、scipy库包的使用

一、python调勇scipy库读取.mat文件

.mat文件:是matlab的文件,如果直接打开,一般看到的就是乱码的,此时可以借用scipy库进行读取该文件

scipy的一些基本使用,见下文

1、使用例子1

import scipy.io as sciopath = r'E:\[EG_code_data]_release\data\images_tracker\00047.mat'reftracker = scio.loadmat(path)['tracker']print(reftracker)

2、 使用例子2

import scipy.io as sciopath = r'E:\workCode\2_DSPR\x2_d\test_01_d_01.mat'matdata = scio.loadmat(path)print(matdata)

从下面的输出结果可以看出,.mat 保存的是一个字典类型的数据,所以可以通过访问对应的键值

通过kernel键访问键值,从上面可以看到 kernel中对应的键值是一个二维数组:

import scipy.io as sciopath = r'E:\workCode\2_DSPR\x2_d\test_01_d_01.mat'matdata = scio.loadmat(path)['kernel']print(matdata)

二、scipy库包的使用

♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠ ⊕ ♠

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。