MATLAB Function Reference |
|
hdf5
HDF5 data type classes
Syntax
Description
MATLAB provides a set of classes to represent HDF5 data types. MATLAB defines a general HDF5 data type class, with subclasses for individual HDF5 data types. The following figure illustrates these classes and subclasses. For more information about a specific class, see the sections that follow. To learn more about the HDF5 data types in general, see the NCSA HDF Web page at http://hdf.ncsa.uiuc.edu. For information about using these classes, see Remarks.
h5array
The HDF5 h5array
class associates a name with an array. The following are the data members of the h5array
class.
Data Members
|
Data
|
Multidimensional array
|
Name
|
Text string specifying the name of the object
|
The following are the methods of the h5array
class. This table shows the function calling syntax. You can also access methods using subscripted reference (dot notation). For an example of the syntax, see HDF5 Enumerated Object Example.
Methods
|
Description
|
Syntax
|
hdf5.h5array
|
Constructs object of class h5array .
|
arr = hdf5.h5array;
arr = hdf5.h5array(data)
where arr is an h5array object and data can be numeric, a cell array, or an HDF5 data type.
|
setData
|
Sets the value of the object's Data member.
|
setData(arr, data)
where arr is an h5array object and data can be numeric, a cell array, or an HDF5 data type.
|
setName
|
Sets the value of the object's Name member.
|
setName(arr, name)
where arr is an h5array object and name is a string or cell array.
|
h5compound
The HDF5 h5compound
class associates a name with a structure, where you can define the field names in the structure and their values. The following are the data members of the h5compound
class.
Data Members
|
Data
|
Multidimensional array.
|
MemberNames
|
Text string specifying the names of fields in the structure
|
Name
|
Text string specifying the name of the object
|
The following are the methods of the h5compound
class.
Methods
|
Description
|
Syntax
|
hdf5.h5compound
|
Constructs object of class h5compound .
|
C = hdf5.h5compound;
C = hdf5.h5compound(mName1,mName2,...)
where C is an h5compound object and mName1 and mName2 are text strings that specify field names. The constructor creates a corresponding data field for every member name.
|
addMember
|
Creates a new field in the structure.
|
addMember(C, mName)
where mName is a text string that specifies the name of the field. This method automatically creates a corresponding data field for the new member name.
|
setMember
|
Sets the value of the Data element associated with a particular field.
|
setData(C, mName, mData)
where C is an h5compound object, mName is the name of a field in the object, and mdata is the value you want to assign to the field. mData can be numeric or an HDF5 data type.
|
setMemberNames
|
Specifies the names of fields in the structure.
|
setData(C, mName1, mName2,...)
where C is an h5compound object and mName1 and mName2 are text strings that specify field names. The constructor creates a corresponding data field for every member name.
|
setName
|
Sets the value of the object's Name member.
|
setName(C, name)
where arr is an h5compound object and name is a string or cell array.
|
h5enum
The HDF5 h5enum
class defines an enumerated types, where you can specify the enumerations (text strings) and the values the represent. The following are the data members of the h5enum
class.
Data Members
|
Data
|
Multidimensional array
|
EnumNames
|
Text string specifying the enumerations, that is, the text strings that represent values.
|
EnumValues
|
The values associated with enumerations
|
Name
|
Text string specifying the name of the object
|
The following are the methods of the h5enum
class.
Methods
|
Description
|
Syntax
|
hdf5.h5enum
|
Constructs object of class h5enum .
|
E = hdf5.h5enum;
E = hdf5.h5enum(eNames, eVals)
where E is an h5enum object, eNames is a cell array of strings, and eVals is vector of integers. eNames and eVals must have the same number of elements.
|
defineEnum
|
Defines the set of enumerations with the integer values they represent.
|
detineEnum(E, eNames, eVals)
where E is an h5enum object, eNames is a cell array of strings, and eVals is vector of integers. eNames and eVals must have the same number of elements.
|
getString
|
Returns data as enumeration's values, not integer values
|
enumdata = getString(E)
where enumdata is a cell array of strings and E is an h5enum object.
|
setData
|
Sets the value of the object's Data member.
|
setData(E, eData)
where E is an h5enum object and eData is a vector of integers.
|
setEnumNames
|
Specifies the enumerations.
|
setEnumNames(E, eNames)
where E is an h5enum object and eNames is a cell array of strings.
|
setEnumValues
|
Specifies the value associated with each enumeration.
|
setEnumValues(E, eVals)
where E is an h5enum object and eVals is a vector of integers.
|
setName
|
Sets the value of the object's Name member.
|
setName(E, name)
where E is an h5enum object and name is a string or cell array.
|
h5string
The HDF5 h5string
class associates a name with an text string and provides optional padding behavior. The following are the data members of the h5string
class.
Data Members
|
Data
|
Text string
|
Length
|
Scalar value
|
Name
|
Text string specifying the name of the object
|
Padding
|
Type of padding to use: 'spacepad' , 'nullterm' , or 'nullpad'
|
The following are the methods of the h5string
class.
Methods
|
Description
|
Syntax
|
hdf5.h5string
|
Constructs object of class h5string .
|
str = hdf5.h5string;
str = hdf5.h5string(data)
str = hdf5.h5string(data, padType)
where str is an h5string object, data is a text string, and padType is a text string specifying one of the supported pad types.
|
setData
|
Sets the value of the object's Data member.
|
setData(str, data)
where str is an h5string object and data is a text string.
|
setLength
|
Sets the value of the object's Length member.
|
setLength(str, lenVal)
where str is an h5string object and lenVal is a scalar.
|
setName
|
Sets the value of the object's Name member.
|
setName(str, name)
where str is an h5string object and name is a string or cell array.
|
setPadding
|
Specifies the value of the object's Padding member.
|
setData(str, padType)
where str is an h5string object and padType is a text string specifying one of the supported pad types.
|
h5vlen
The HDF5 h5vlen
class associates a name with an array. The following are the data members of the h5vlen
class.
Data Members
|
Data
|
Multidimensional array
|
Name
|
Text string specifying the name of the object
|
The following are the methods of the h5vlen
class.
Methods
|
Description
|
Syntax
|
hdf5.h5vlen
|
Constructs object of class h5vlen .
|
V = hdf5.h5vlen;
V = hdf5.h5vlen(data)
where V is h5vlen object and data can be a scalar, vector, text string, cell array, or an HDF5 data type.
|
setData
|
Sets the value of the object's Data member.
|
setData(V, data)
where V is h5vlen object and data can be a scalar, vector, text string, cell array, or an HDF5 data type.
|
setName
|
Sets the value of the object's Name member.
|
setName(V, name)
where name is a string or cell array.
|
Remarks
The hdf5read
function uses the HDF5 data type classes when the data it is reading from the HDF5 file cannot be represented in the workspace using a native MATLAB data type. For example, if an HDF5 file contains a data set made up of an enumerated data type which cannot be represented in MATLAB, hdf5read
uses the HDF5 h5enum
class to represent the data. An h5enum
object has data members that store the enumerations (text strings), their corresponding values, and the enumerated data.
You might also need to use these HDF5 data type classes when using the hdf5write
function to write data from the MATLAB workspace to an HDF5 file. By default, hdf5write
can convert most MATLAB data to appropriate HDF5 data types. However, if this default data type mapping is not suitable, you can create HDF5 data types directly.
Examples
HDF5 Array Object Example
- Create an array in the MATLAB workspace.
- Create an HDF5
h5array
object, passing the MATLAB array as the only argument to the constructor.
- Assign a name to the object.
HDF5 Compound Object Example
- Create several variables in the MATLAB workspace.
- Create an HDF5
h5compound
object, specifying member names. The method creates corresponding Data
fields for each member name.
- Set the values of the members.
setMember(dset2,'temp1',89)
setMember(dset2,'temp2',95)
setMember(dset2,'temp3',108)
dset2
hdf5.h5compound:
Name: ''
Data: {[89] [95] [108]}
MemberNames: {'temp1' 'temp2' 'temp3'}
HDF5 Enumerated Object Example
- Create an HDF5
h5enum
object.
- Define the enumerations and their corresponding values. The values must be integers.
enum_obj
now contains the definition of the enumeration that associates the names RED
, GREEN
, and BLUE
with the numbers 1, 2, and 3.
- Add enumerated data to the object.
- Use the
h5enum
getString
method to read the data as enumerated values, rather than integers.
HDF5 h5string Object Example
Create an HDF5 string object.
HDF5 h5string Object Example
Create an HDF5 h5vlen
object.
See Also
hdf5read
, hdf5write
| hdf | | hdf5info | |
© 1994-2005 The MathWorks, Inc.