python中.mat文件怎么读取
推荐回答
python中读取mat文件在python中可以使用scipy.io中的函数loadmat()读取mat文件,函数savemat保存文件。1、读取文件如上例:1234567#coding:UTF-8 import scipy.io as scio dataFile = 'E://data.mat'data = scio.loadmat(dataFile)注意,读取出来的data是字典格式,可以通过函数type(data)查看。1print type(data)结果显示1<type 'dict'>找到mat文件中的矩阵:1print data['A']结果显示[[ 0. 0. 0. 0. 0. 0. 0.0. 0. 0. 0. 0. 0. 0.。。。。。。。。。。。0. 0. 0. 0. 0. 0. 0.0.36470588 0.90196078 0.99215686 0.99607843 0.99215686 0.992156860.78431373 0.0627451 0. 0. 0. 0. 0.0. 0. 0. 0. 0. 0. 0.。。。。。。。。。。。。0.94117647 0.22745098 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.30196078。。。。。。。0. 0. 0. 0. 0. 0. 0.0. 0. 0. 0. 0. 0. 0. ]]格式为:<type 'numpy.ndarray'>即为numpy中的矩阵格式。