I have some data that I share between Python and Matlab. I used to do it by saving NumPy arrays in MATLAB-style .mat files but would like to switch to HDF5 datasets. However, I've noticed a funny feature: when I save a NumPy array in an HDF5 file (using h5py) and then read it in Matlab (using h5read), it ends up being transposed. Is there something I'm missing?
Python code:
import numpy as np
import h5py
mystuff = np.random.rand(10,30)
f = h5py.File('/home/user/test.h5', 'w')
f['mydataset'] = mystuff
f.close()
Matlab code:
mystuff = h5read('/home/user/test.h5', '/mydataset');
size(mystuff) % 30 by 10