矩阵的保存和读取

import  numpy as np
import scipy.io as scio
N=np.zeros((7,6))
N[0,:]=[1,2,3,0,4,0]
N[1,:]=[0,3,0,5,0,1]
N[2,:]=[2,0,1,5,1,0]
N[3,:]=[3,2,0,0,2,4]
N[4,:]=[11,3,0,5,0,1]
N[5,:]=[12,1,1,5,1,0]
N[6,:]=[13,2,0,0,2,4]#将矩阵保存
Embedding_UI = 'E://Embedding_UI.mat'
#N是需要保存的矩阵,A为字典名,读取的方便,保存为新矩阵dataNew=Embedding_UI
scio.savemat(Embedding_UI, {'train':N})

#读取矩阵,矩阵的名字为train.mat dataFile1 = 'E://Embedding_UI.mat' # mat文件路径,data为名字,其中的变量名为A data = scio.loadmat(dataFile1) train = data['train']

 

相关文章:

  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-12-09
  • 2021-05-30
  • 2021-05-16
猜你喜欢
  • 2021-12-28
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2021-12-09
相关资源
相似解决方案