h5readatt
Read attribute from HDF5 file
Description
Examples
Read Group Attributes
Read the attribute attr2
from the root group of the HDF5 file example.h5
.
val = h5readatt('example.h5','/','attr2')
val = 2x2 int32 matrix
0 2
1 3
Read Dataset Attributes
Read the attribute units
from the dataset lon
in the HDF5 file example.h5
.
val = h5readatt('example.h5','/g4/lon','units')
val = 'degrees_east'
Input Arguments
filename
— Filename
string scalar | character vector
Filename of an existing HDF5 file, specified as a string scalar or character vector.
Depending on the location of your file, filename
can take one of
these forms.
Location | Form | ||||||||
---|---|---|---|---|---|---|---|---|---|
Current folder | Specify the name of the file in
Example:
| ||||||||
Other folders | If the file is not in the current folder or in a folder on
the MATLAB® path, then specify the full or relative path in
Example:
Example:
| ||||||||
Uniform resource locator (URL) (since R2024b) | If the file is located by an internet URL, then
Example:
| ||||||||
Remote location | If the file is stored at a remote location, then
Based on your remote location,
For more information, see Work with Remote Data. Example:
|
If your file consists of several physical files using the Family driver, specify
filename
using a format specifier. For example, to use the Family driver with the two filesfamily0.h5
andfamily1.h5
, specifyfilename
as"family%d.h5"
.If your file consists of several physical files using the Multi driver or the Split driver, specify
filename
as the leading prefix of the names of the physical files. For example, to use the Multi driver with the six filesmulti-b.h5
,multi-g.h5
,multi-l.h5
,multi-o.h5
,multi-r.h5
, andmulti-s.h5
, specifyfilename
as"multi"
.
loc
— Location in file
character vector | string scalar
Location in the file, specified as a character vector or string scalar
containing the full path of an existing group or dataset to which the
attribute belongs. To read an attribute from the root group of the file,
specify '/'
as the location.
attr
— Attribute name
character vector | string scalar
Attribute name, specified as a character vector or string scalar containing the name of an attribute belonging to a group or dataset.
Limitations
MATLAB does not support internet URLs that require authentication.
MATLAB Online™ supports internet URLs associated with Microsoft® OneDrive™ files and folders, while the installed version of MATLAB supports only local OneDrive files.
Version History
Introduced in R2011aR2024b: Read attributes from HDF5 files over HTTP and HTTPS
You can read attributes from HDF5 files stored in primary online sources by using
the h5readatt
function with an internet URL.
R2020b: Read attributes from HDF5 files at a remote location
You can read attributes from HDF5 files in remote locations, such as Amazon S3, Windows Azure Blob Storage, and HDFS.
R2020b: Read attributes from HDF5 files with Unicode names
You can read attributes from HDF5 files whose names are encoded as Unicode characters.
R2020a: Read nonscalar string attributes as MATLAB string arrays
h5readatt
returns HDF5 string array attributes as MATLAB string arrays rather than cell arrays of character vectors. Single
(scalar) HDF5 string attributes are returned as MATLAB character vectors.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)