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

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Python數(shù)據(jù)和matlab數(shù)據(jù)轉(zhuǎn)換

2019-11-14 11:40:02
字體:
供稿:網(wǎng)友

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

1. Python數(shù)據(jù)和matlab數(shù)據(jù)轉(zhuǎn)換

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

對(duì)于高版本的.mat數(shù)據(jù)讀寫,需要使用另外的接口

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)
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 新密市| 浦县| 新晃| 华容县| 都江堰市| 蒲城县| 武强县| 宜章县| 祁连县| 肇东市| 郧西县| 信阳市| 沅江市| 宁安市| 廊坊市| 定兴县| 邯郸市| 赫章县| 巩义市| 高台县| 北碚区| 张家界市| 固镇县| 女性| 沂源县| 昌图县| 合水县| 琼中| 静安区| 长葛市| 曲松县| 达孜县| 乌兰察布市| 张家口市| 洛阳市| 伊吾县| 钟祥市| 祁连县| 阳城县| 乳山市| 林周县|