How to save .mat file into hdf5 in matlab?

43 次查看(过去 30 天)
I have .mat file and i want to convert them into dataset using h5write but i got error.
a = load('file.mat');
h5write('a.h5', a)
Error
Error using h5write (line 96)
The value of 'Data' is invalid. Expected DATA to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, string
Instead its type was struct.

回答(1 个)

Star Strider
Star Strider 2021-9-18
I have no recent experience with HDF5 files, however the h5write documentation for data indicates that it must be a numeric matrix or a MATLAB string array. Depending on what the structure contains, the struct2table (or struct2cell) functions would likely be required first, then table2array for a table.
That appears to me to be more involved than it should be, however that appears to be the only option.
And that only if the original structure and the data in it permits those conversions.
.
  2 个评论
Faheem Ur Rehman
Faheem Ur Rehman 2021-9-19
Thank you for your answer. I have what you write. but write now facing another error. please help
Error using h5create (line 98)
The value of 'Size' is invalid. Expected SIZE to be nonnegative.
Star Strider
Star Strider 2021-9-19
I cannot help you with that, other than to caution you to be certain that 'Size' is greater than 0.
.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by