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

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

Python數據和matlab數據轉換

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

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)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 千阳县| 抚松县| 蓝山县| 广宗县| 科技| 武穴市| 汉川市| 柏乡县| 临安市| 台前县| 武冈市| 太原市| 衢州市| 石台县| 安义县| 乐安县| 曲水县| 安宁市| 茌平县| 永泰县| 阿拉善右旗| 杭锦后旗| 双辽市| 建始县| 门头沟区| 广水市| 上蔡县| 孝昌县| 闽侯县| 安图县| 修水县| 迁安市| 彰化市| 桓仁| 冕宁县| 安丘市| 景谷| 屏南县| 祁连县| 安图县| 诸暨市|