This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Determine the offset of a field within a structure


H5ML.hoffset is not recommended. Use H5T instead.



This function is used to determine the offset (in bytes) of a structure, H5T.insert(file_type,'a', offset(1), dtype(1));, within a field. It is used when constructing an HDF5 COMPOUND type. It is designed to correspond to the HDF5 HOFFSET macro. For more details about the operation of the HOFFSET macro, please consult the HDF5 documentation.

Function parameters:

offsetThe byte offset of the field within the structure.
structureThe structure which contains the specified fieldname.
fieldnameThe field for which the offset is determined.


This function is deprecated. It can only be used in workflows that do not include a field that is itself an HDF5 COMPOUND or of variable length. To handle these cases, the offsets should be computed directly. For example, in the case above, a file dataspace for such a compound could be created with:

dtype(1) = H5T.copy('H5T_NATIVE_INT');
dtype(2) = H5T.copy('H5T_NATIVE_DOUBLE');
dtype(3) = H5T.copy('H5T_NATIVE_FLOAT');
for j = 1:3, sz(j,1) = H5T.get_size(dtype(j)); end
% The first offset would always be zero and the size of the last 
% field does not matter.
offset(1) = 0;
offset(2:3) = cumsum(sz(1:2));
file_type = H5T.create('H5T_COMPOUND',sum(sz));
H5T.insert(file_type,'a', offset(1), dtype(1));
H5T.insert(file_type,'b', offset(2), dtype(2));
H5T.insert(file_type,'c', offset(3), dtype(3));

See Also

Was this topic helpful?