Writing Compound Data into Groups in HDF5 files

조회 수: 12 (최근 30일)
Simon
Simon 2012년 7월 19일
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 posted a question about this and was helped out by being pointed towards the following link: http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/api18-m.html. I used the Write Compound Data script to solve the problem.
However, I need to nest the data inside a number of directories inside the hdf5 file. For example /hospital/patient/patientdata. I think the hdf5 terminology is "groups"
I worked out how to do this using MATLAB h5write command but this only works for numeric datasets and not the compound data that I'm trying to write. Could someone tell me what changes I need to make to the example script http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/matlab/HDF5_M_Examples/h5ex_t_cmpd.m to get it writing the data inside of a set of groups?

채택된 답변

John
John 2012년 7월 19일
Change line 89 from
dset = H5D.create (file, DATASET, filetype, space, 'H5P_DEFAULT');
to (for example)
plist = 'H5P_DEFAULT';
g1 = H5G.create(file,'g1',plist,plist,plist);
g2 = H5G.create(g1,'g2',plist,plist,plist);
dset = H5D.create (g2, DATASET, filetype, space, 'H5P_DEFAULT');
You then get a dataset with full path name '/g1/g2/DS1'
You also have to change the line in the script that tries to re-open the dataset, just give it the full path name.
  댓글 수: 1
Simon
Simon 2012년 7월 20일
Thanks, John. That works well.
In the script, does DIM0 refer to the number of observations or the number of arrays in the structure? It's hard to tell because there are 4 of each.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 HDF5에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by