Reading HDF5 in MATLAB

In Reading a mat file into Python, I learned how to read a mat file for Python programs. What about the reverse? In MATLAB, the relevant functions are hdf5info and hdf5read.

First, we need to save data in Python by using h5py:

import numpy as np
import h5py

f = h5py.File('FileName', 'w')

dataset = f.create_dataset('VariableName', data = numpyArrayContainingData)

f.close()

You may check the h5py document regarding the method create_dataset.

Then, try the following in MATLAB:

hdf5info('FileName')
hdf5read('FileName', 'VariableName')
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s