23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7 Working with Scientific Data Formats<br />

'Full'<br />

'Full'<br />

'Full'<br />

2 To read all of the data in the CDF file, use the cdfread function. The<br />

function returns the data in a 24-by-5 cell array. The five columns of data<br />

correspond to the five variables; the 24 rows correspond to the 24 records<br />

associated with the Time variable and padding elements for the rows<br />

associated with the other variables. The padding value used is specified<br />

in the CDF file.<br />

data = cdfread('example.cdf');<br />

whos data<br />

Name Size Bytes Class Attributes<br />

data 24x5 14784 cell<br />

3 To read the data associated with a particular variable, use the 'Variable'<br />

parameter, specifying a cell array of variable names as the value of this<br />

parameter. Variable names are case sensitive. For example, the following<br />

code reads the Longitude and Latitude variables from the file. The return<br />

value data is a 24-by-2 cell array, where each cell contains int8 data.<br />

var_time = cdfread('example.cdf','Variable',{'Longitude','Latitude'});<br />

whos var_time<br />

Name Size Bytes Class Attributes<br />

var_time 24x1 4608 cell<br />

Speeding Up Read Operations<br />

The cdfread function offers two ways to speed up read operations when<br />

working with large data sets:<br />

• Reducing the number of elements in the returned cell array<br />

• Returning CDF epoch values as <strong>MATLAB</strong> serial date numbers rather than<br />

as <strong>MATLAB</strong> cdfepoch objects<br />

7-4

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

Saved successfully!

Ooh no, something went wrong!