String vectors in HDF5

12 ビュー (過去 30 日間)
Peter Felfer
Peter Felfer 2020 年 7 月 15 日
回答済み: Deepak 2024 年 10 月 18 日
Hi,
does anyone know if i can create a dataset in an HDF5 file from a string array (or char cell array) in Matlab?
Thanks heaps in advance,
Peter

回答 (1 件)

Deepak
Deepak 2024 年 10 月 18 日
Hi Peter,
As I understand it, you want to know how we can create and store data in an HDF5 file from a string array/ char cell array in MATLAB.
We can accomplish this using “h5create” and “h5write” functions in MATLAB. We specify the output file name, data types, and size of the file in “h5create” to create the output dataset file. Then we can call “h5write” function to write the string/char cell array data into the output HDF5 file. We can also read and display the output data using the “h5read” function in MATLAB.
Here is the sample MATLAB code for the same:
charCellArray = {'Hello', 'World', 'MATLAB', 'HDF5'};
h5create('mydata2.h5', '/dataset', size(charCellArray), 'Datatype', 'string');
h5write('mydata2.h5', '/dataset', charCellArray);
data = h5read('mydata2.h5', '/dataset');
disp(data);
Please find attached the documentation of functions used for reference:
I hope this helps in resolving the issue.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by