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

Common Data Format (CDF) Files<br />

<strong>MATLAB</strong> includes functions that let you import and export data using the<br />

Common Data Format (CDF). CDF was created by the National Space<br />

Science Data Center (NSSDC) to provide a self-describing data storage<br />

and manipulation format that matches the structure of scientific data and<br />

applications (i.e., statistical and numerical methods, visualization, and<br />

management). The <strong>MATLAB</strong> CDF functions are described in the following<br />

sections:<br />

• “Getting Information About CDF Files” on page 7-2<br />

• “Importing Data from a CDF File” on page 7-3<br />

• “Exporting Data to a CDF File” on page 7-6<br />

Getting Information About CDF Files<br />

To get information about the contents of a CDF file, use the cdfinfo function.<br />

The cdfinfo function returns a structure containing general information<br />

about the file and detailed information about the variables and attributes in<br />

the file.<br />

ThefollowingexamplereturnsinformationaboutthesampleCDFfile<br />

included with <strong>MATLAB</strong>. To determine the variables contained in the file, view<br />

the Variables field. This field contains a cell array that lists all the variables<br />

in the file with information that describes the variable, such as name, size, and<br />

data type. For an example, see “Importing Data from a CDF File” on page 7-3.<br />

Note Because cdfinfo creates temporary files, make sure that your current<br />

working directory is writable before attempting to use the function.<br />

info = cdfinfo('example.cdf')<br />

info =<br />

Filename: 'example.cdf'<br />

FileModDate: '09-Mar-2001 16:45:22'<br />

FileSize: 1240<br />

7-2

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

Saved successfully!

Ooh no, something went wrong!