Matlab: Read Hdf5 files

If you need to read in a hdf5 file (.h5) in matlab, use the function h5read.

The syntax is

data = h5read(filename,datasetname);

 

The "filename" is obvious, e.g. /the/path/to/the/file/name.h5. The "datasetname" can be found by using the tool hdfview or by using the linux terminal tool h5ls

installation:

 sudo apt-get install hdf5-tools

usage:

h5ls name_of_h5_file.h5

gives you an output like

DISPARITY                Dataset {7, 7, 375, 375}
coherence_h              Dataset {7, 7, 375, 375}
coherence_v              Dataset {7, 7, 375, 375}
disparity_h              Dataset {7, 7, 375, 375}
disparity_v              Dataset {7, 7, 375, 375}
 

the names in the first column are the datasetname, so e.g.

data = h5read('name_of_h5_file.h5', 'coherence_v');

 

blog_tags: 

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <img> <br> <p> <span>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Use [collapse] and [/collapse] to create collapsible text blocks. [collapse collapsed] or [collapsed] will start with the block closed.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Code snippets in <code>...</code> or <source>...</source> automatically will be pretty printed.
  • Use [collapse] and [/collapse] to create collapsible text blocks. [collapse collapsed] or [collapsed] will start with the block closed.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Target Image