Example (requires Python >= 2.6 with the NumPy and h5py >= 2.1 packages):
import hdf5storage # get code on https://pypi.python.org/pypi/hdf5storage/0.1.3
matcontent = {}
matcontent[u'some_numbers'] = [10, 50, 20] # each key must be a unicode string
hdf5storage.write(matcontent, '.', 'test.mat', store_python_metadata=False, matlab_compatible=True)
In Matlab:
If you want to have a matrix instead of a cell array in Matlab:
import hdf5storage # get code on https://pypi.python.org/pypi/hdf5storage/0.1.3
import numpy as np
matcontent = {}
matcontent[u'some_numbers'] = np.array([10, 50, 20]) # each key must be a unicode string
hdf5storage.write(matcontent, '.', 'test2.mat', matlab_compatible=True)
As you will notice, the second example is much faster (>x10).
More generally, refer to the documentation for the data storage matching: