用Matlab编写:
test = {'Hello', 'world!'; 'Good', 'morning'; 'See', 'you!'};save('data.mat', 'test', '-v7.3') % v7.3 so that it is readable by h5py
使用Python进行阅读(适用于任何数字,行或列,但假定每个单元格都是字符串):
import h5pyimport numpy as npdata = []with h5py.File("data.mat") as f: for column in f['test']: row_data = [] for row_number in range(len(column)): row_data.append(''.join(map(unichr, f[column[row_number]][:])))data.append(row_data)print dataprint np.transpose(data)
输出:
[[u'Hello', u'Good', u'See'], [u'world!', u'morning', u'you!']][[u'Hello' u'world!'] [u'Good' u'morning'] [u'See' u'you!']]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)