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.


Return the size (in bytes) of a variable as stored on disk

    Note:   H5ML.sizeof is not recommended. Use H5T instead.



This function is used to determine the size (in bytes) of a structure or other (simple) variable. It is designed to correspond to the C sizeof() operator as it is used during the creation of HDF5 datatypes, especially the HDF5 COMPOUND type.

Function parameters:

sizeThe size (in bytes) of the variable as it would be stored on disk.
argThe variable for which the size is being sought.


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?