国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Python數據和matlab數據轉換

2019-11-14 11:43:48
字體:
來源:轉載
供稿:網友

http://blog.csdn.net/landiaoxinqing/article/details/48622057

1. Python數據和matlab數據轉換

1.1 Python加載和寫入.mat文件

File IO (scipy.io)

See alsonumpy-reference.routines.io (in numpy)1212

MATLAB files

*loadmat(file_name[, mdict, appendmat])* Load MATLAB file*savemat(file_name, mdict[, appendmat, ...])* Save a dictionary of names and arrays into a MATLAB-style .mat file.*whosmat(file_name[, appendmat])* List variables inside a MATLAB file123123

How to do

import scipy.io as siomat_contents = sio.loadmat('octave_a.mat')mat_contents>>>{'a': array([[[ 1., 4., 7., 10.], [ 2., 5., 8., 11.], [ 3., 6., 9., 12.]]]), '__version__': '1.0', '__header__': 'MATLAB 5.0 MAT-file, written by Octave 3.6.3, 2013-02-17 21:02:11 UTC', '__globals__': []}oct_a = mat_contents['a']oct_a>>>array([[[ 1., 4., 7., 10.], [ 2., 5., 8., 11.], [ 3., 6., 9., 12.]]])oct_a.shape>>>(1, 3, 4)sio.savemat('np_vector.mat', {'vect':vect})123456789101112131415161718192021123456789101112131415161718192021

If you want to inspect the contents of a MATLAB file without reading the data into memory, use the whosmat command:

sio.whosmat('octave_a.mat')>>>[('a', (1, 3, 4), 'double')]1212

對于高版本的.mat數據讀寫,需要使用另外的接口

import h5pydatasets = F:/MuraDefectData_6X6_10W_NonZCA_Batches.mat'f = h5py.File(datasets, 'r')TotalBatchImg = f['TotalBatchImg']TotalBatchImg = np.array(TotalBatchImg)wSize = f['wSize']wSize = np.array(wSize)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宝丰县| 西乌| 临海市| 兴仁县| 惠安县| 合江县| 通江县| 扶绥县| 中方县| 井冈山市| 内丘县| 深泽县| 昆山市| 汾西县| 汶川县| 同江市| 古交市| 皮山县| 新蔡县| 泉州市| 通渭县| 漳浦县| 桂阳县| 通海县| 尚志市| 揭阳市| 益阳市| 包头市| 汉沽区| 苍南县| 菏泽市| 屏南县| 梓潼县| 高州市| 汾西县| 宕昌县| 宁波市| 县级市| 当阳市| 锦屏县| 定边县|