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

To access the data in the data set in the <strong>MATLAB</strong> workspace, you must access<br />

the Data field in the object.<br />

This example converts a simple <strong>MATLAB</strong> vector into an h5array object and<br />

then displays the fields in the object:<br />

vec = [ 1 2 3];<br />

hhh = hdf5.h5array(vec);<br />

hhh:<br />

Name: ''<br />

Data: [1 2 3]<br />

hhh.Data<br />

ans =<br />

1 2 3<br />

Examples of Using the <strong>MATLAB</strong> HDF5 Data Type Objects. This example<br />

uses an HDF5 enumeration object for enumerated data:<br />

1 Create an HDF5 enumerated object.<br />

enum_obj = hdf5.h5enum;<br />

2 Define the enumerated values and their corresponding names.<br />

enum_obj.defineEnum({'RED' 'GREEN' 'BLUE'}, uint8([1 2 3]));<br />

enum_obj now contains the definition of the enumeration that associates<br />

the names RED, GREEN, andBLUE with the numbers 1, 2, and 3.<br />

3 Add enumerated data to the object.<br />

enum_obj.setData(uint8([2 1 3 3 2 3 2 1]));<br />

In the HDF5 file, these numeric values map to the enumerated values<br />

GREEN, RED, BLUE, BLUE, GREEN, etc.<br />

7-20

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

Saved successfully!

Ooh no, something went wrong!