Writing data as a table in a hdf5 file.

I'm trying to write MATLAB data to an existing database of hdf5 files. Data in the database is currently being stored as table. The tables' columns can be different data types such as an integer or a string etc. and the columns also have labels like "longitude", "Name of patient" etc as a property of the table.
I think MATLAB's struct datatype is equivalent to the hdf5 table but I'm not sure how to save it. MATLAB says that the array is not numeric when I try to save the struct, DataStruct, in the example below.
h5write('h5testfile.h5', '/foo/Test', DataStruct);
Any ideas how I can fix this problem?

답변 (1개)

John
John 2012년 7월 13일

0 개 추천

Only numeric data can be written with H5WRITE. In order to write table or compound data, you will need to use "formal" interfaces that wrap the HDF5 library API.
We provided the HDF Group with MATLAB versions of their own example codes that may help demonstrate how to do this. I would suggest that you go to http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-m.html and check out the compound data examples. Let me know how it goes.

댓글 수: 3

Simon
Simon 2012년 7월 16일
편집: Simon 2012년 7월 16일
Thanks. That example was quite helpful. We were able to create a compound file with our own data. Could you tell me how I'd have to change it to place the table within a number of subfolders inside the hdf5 file.
For example, inside the group '/foo/bar' or something like that? I tried
plist = 'H5P_DEFAULT';
foogroup = H5G.create(file,'foo',plist,plist,plist);
bargroup = H5G.create(foogroup ,'bar',plist,plist,plist);
before the line
dset = H5D.create (bargroup, DATASET, filetype, space, 'H5P_DEFAULT');
but it doesn't seem to create a valid h5 file.
John
John 2012년 7월 18일
I don't think I have enough information to tell what might be going wrong.

댓글을 달려면 로그인하십시오.

질문:

2012년 7월 13일

댓글:

2016년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by