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

model of one particular HDF4 API: the HDF4 Scientific Data (SD) API. For a<br />

complete list of the HDF4 APIs supported by <strong>MATLAB</strong> and the functions you<br />

use to access each one, see the hdf reference page.<br />

Note This section does not attempt to describe all HDF4 features and<br />

routines. To use the <strong>MATLAB</strong> HDF4 functions effectively, you must refer to<br />

the official NCSA documentation at the HDF Web site (www.hdfgroup.org).<br />

Topics covered include<br />

• “Understanding the HDF4 to <strong>MATLAB</strong> Syntax Mapping” on page 7-56<br />

• “Example: Importing Data Using the HDF4 SD API Functions” on page<br />

7-57<br />

• “Example: Exporting Data Using the HDF4 SD API Functions” on page<br />

7-63<br />

• “Using the <strong>MATLAB</strong> HDF4 Utility API” on page 7-70<br />

Understanding the HDF4 to <strong>MATLAB</strong> Syntax Mapping<br />

Each HDF4 API includes many individual routines that you use to read<br />

data from files, write data to files, and perform other related functions. For<br />

example,theHDF4ScientificData(SD) API includes separate C routines to<br />

open (SDopen), close (SDend), andreaddata(SDreaddata).<br />

Instead of supporting each routine in the HDF4 APIs, <strong>MATLAB</strong> provides a<br />

single function that serves as a gateway to all the routines in a particular<br />

HDF4 API. For example, the HDF Scientific Data (SD) API includes the C<br />

routine SDend to close an HDF4 file:<br />

status = SDend(sd_id); /* C code */<br />

To call this routine from <strong>MATLAB</strong>, use the <strong>MATLAB</strong> function associated with<br />

the SD API, hdfsd. Youmustspecifythenameoftheroutine,minustheAPI<br />

acronym, as the first argument and pass any other required arguments to the<br />

routine in the order they are expected. For example,<br />

status = hdfsd('end',sd_id); % <strong>MATLAB</strong> code<br />

7-56

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

Saved successfully!

Ooh no, something went wrong!