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

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

Python數據和matlab數據轉換

2019-11-14 12:38:17
字體:
來源:轉載
供稿:網友

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)
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 睢宁县| 江门市| 唐河县| 水富县| 三门县| 建昌县| 郴州市| 麻阳| 凤翔县| 安徽省| 华阴市| 罗城| 宕昌县| 根河市| 武城县| 旌德县| 大同市| 宣城市| 乐业县| 壤塘县| 柳江县| 洛阳市| 瑞丽市| 濉溪县| 万山特区| 徐汇区| 碌曲县| 新巴尔虎右旗| 时尚| 兖州市| 唐海县| 方山县| 乡宁县| 平乐县| 孝感市| 休宁县| 泸西县| 榆社县| 颍上县| 鸡东县| 田东县|