码迷,mamicode.com
首页 > 编程语言 > 详细

python中读取mat文件

时间:2019-04-02 12:29:13      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:atl   存储   读取   dict   bsp   数据   数组   span   style   

 mat数据格式是Matlab的数据存储的标准格式

在python中可以使用scipy.io中的函数loadmat()读取mat文件。

import scipy.io as scio
 
path = ex3data1.mat
data = scio.loadmat(path)
type(data)

dict #data是字典格式

data.keys() #查看字典的键

dict_keys([‘__header__‘, ‘__version__‘, ‘__globals__‘, ‘X‘, ‘y‘])

X1 = data[‘X‘] #选择需要的数据;数组格式

array([[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]])

 

python中读取mat文件

标签:atl   存储   读取   dict   bsp   数据   数组   span   style   

原文地址:https://www.cnblogs.com/tongtong123/p/10641599.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!