教程集 www.jiaochengji.com
教程集 >  Python编程  >  Python入门  >  正文 python怎样读mat文件格式

python怎样读mat文件格式

发布时间:2021-03-22   编辑:jiaochengji.com
教程集为您提供python怎样读mat文件格式等资源,欢迎您收藏本站,我们将为您提供最新的python怎样读mat文件格式资源

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培训视频,尽在python学习网,欢迎在线学习!

您可能感兴趣的文章:
python怎么查看mat格式的文件
python怎样读mat文件格式
python mat是什么文件
Python怎么计算矩阵的和积
python怎么读取文件内容
jQuery 版本的文本输入框检查器Input Check
python怎么读取文本文件
Python如何计算两行数据内积
python怎么读取txt文件内容
python怎么读取和写入excel表格

[关闭]
~ ~