国产探花免费观看_亚洲丰满少妇自慰呻吟_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)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 噶尔县| 南木林县| 吉首市| 师宗县| 正阳县| 昌平区| 白山市| 城口县| 杂多县| 呈贡县| 达拉特旗| 宽城| 长寿区| 晋宁县| 望都县| 庄浪县| 鱼台县| 定南县| 平罗县| 肇东市| 阿瓦提县| 门头沟区| 阳信县| 定襄县| 邳州市| 绥宁县| 陇川县| 泸西县| 福贡县| 宜黄县| 高平市| 铜川市| 嘉兴市| 彩票| 北碚区| 波密县| 六盘水市| 突泉县| 新和县| 丰宁| 庆云县|