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 />

strings. If that is not the mapping you intend, use HDF5 objects to specify<br />

the correct mapping. In addition, note that HDF5 makes a distinction<br />

between the size of a data set and the size of a data type. In <strong>MATLAB</strong>, data<br />

types are always scalar. In HDF5, data types can have a size; that is, types<br />

canbeeitherscalar(like<strong>MATLAB</strong>)orm-by-n. InHDF5,a5-by-5dataset<br />

containing a single uint8 value in each element is distinct from a 1-by-1 data<br />

set containing a 5-by-5 array of uint8 values. In the first case, the data set<br />

contains 25 observations of a single value; in the second case, the data set<br />

contains a single observation with 25 values. For more information about<br />

the <strong>MATLAB</strong> HDF5 data type objects, see “Mapping HDF5 Data Types to<br />

<strong>MATLAB</strong> Data Types” on page 7-18.<br />

Mapping HDF5 Data Types to <strong>MATLAB</strong> Data Types<br />

When the hdf5read function reads data from an HDF5 file into the <strong>MATLAB</strong><br />

workspace, it maps HDF5 data types to <strong>MATLAB</strong> data types, depending on<br />

whether the data in the data set is in an atomic data type or a nonatomic<br />

composite data type.<br />

Mapping Atomic Data Types. Atomic data types describe commonly used<br />

binary formats for numbers (integers and floating point) and characters<br />

(ASCII). Because different computing architectures and programming<br />

languages support different number and character representations, the HDF5<br />

library provides the platform-independent data types, which it then maps to<br />

an appropriate data type for each platform. For example, a computer may<br />

support 8-, 16-, 32-, and 64-bit signed integers, stored in memory in little<br />

endian byte order.<br />

If the data in the data set is stored in one of the HDF5 atomic data types,<br />

hdf5read uses the equivalent <strong>MATLAB</strong> data type to represent the data. Each<br />

data set contains a Datatype field that names the data type. For example,<br />

the data set /g2/dset2.2 inthesampleHDF5fileincludesatomicdataand<br />

data type information.<br />

dtype = dataset1.Datatype<br />

dtype =<br />

Name: []<br />

Class: 'H5T_IEEE_F32BE'<br />

Elements: []<br />

7-18

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

Saved successfully!

Ooh no, something went wrong!