23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

7 Working with Scientific Data Formats<br />

Determining the Contents of an HDF5 File<br />

HDF5 files can contain data and metadata, called attributes. HDF5files<br />

organize the data and metadata in a hierarchical structure similar to the<br />

hierarchical structure of a UNIX file system.<br />

In an HDF5 file, the directories in the hierarchy are called groups. Agroup<br />

can contain other groups, data sets, attributes, links, and data types. A data<br />

set is a collection of data, such as a multidimensional numeric array or string.<br />

An attribute is any data that is associated with another entity, such as a data<br />

set. A link is similar to a UNIX file system symbolic link. Links are a way to<br />

reference data without having to make a copy of the data.<br />

Data types are a description of the data in the data set or attribute. Data<br />

types tell how to interpret the data in the data set. For example, a file might<br />

contain a data type called “Reading” that is comprised of three elements: a<br />

longitude value, a latitude value, and a temperature value.<br />

To explore the hierarchical organization of an HDF5 file, use the hdf5info<br />

function. For example, to find out what the sample HDF5 file, example.h5,<br />

contains, use this syntax:<br />

fileinfo = hdf5info('example.h5');<br />

hdf5info returns a structure that contains various information about the<br />

HDF5 file, including the name of the file and the version of the HDF5 library<br />

that <strong>MATLAB</strong> is using:<br />

fileinfo =<br />

Filename: 'example.h5'<br />

LibVersion: '1.6.5'<br />

Offset: 0<br />

FileSize: 8172<br />

GroupHierarchy: [1x1 struct]<br />

In the information returned by hdf5info, look at the GroupHierarchy field.<br />

This field is a structure that describes the top-level group in the file, called<br />

the root group. Using the UNIX convention, HDF5 names this top-level group<br />

/ (forward slash), as shown in the Name field of the GroupHierarchy structure.<br />

toplevel = fileinfo.GroupHierarchy<br />

7-12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!