Reading multiple datasets in hdf5

22 ビュー (過去 30 日間)
Amit Sinha
Amit Sinha 2023 年 5 月 24 日
回答済み: Animesh 2023 年 5 月 30 日
I have an HDF5 file format where the datasets are in a group like /abc/xyz1 to /abc/xyznnn
All these have similar datasets: name, age, loc
How do I loop through these n subgroups to read all the data from the hdf5 file?

回答 (1 件)

Animesh
Animesh 2023 年 5 月 30 日
Hello!
You can use MATLAB's h5info function to get information about the contents of the HDF5 file(including the names of the datasets and groups) and h5read to read the data from the dataset.
You can do something like this to read all the data from all subgroups of "/abc":
filename = 'yourfile.h5';
info = h5info(filename, '/abc');
subgroup_names = {info.Groups.Name};
for i = 1:length(subgroup_names)
groupname = subgroup_names{i};
name = h5read(filename, strcat(groupname, '/name'));
age = h5read(filename, strcat(groupname, '/age'));
loc = h5read(filename, strcat(groupname, '/loc'));
% Do something with the data
end
You may refer to the following documentation for more information:

カテゴリ

Help Center および File ExchangeHDF5 についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by