MATLAB Cell Array in HDF5?

Is there something with equivalent functionality to Matlab's cell
array in HDF5? I am converting my code from Matlab output to HDF5
output, and I have a collection of heterogeneous structs that I would
like to store in a a single array. I was previously outputting these
to a cell array in Matlab, but I'm having trouble finding an example
of an equivalent data structure in HDF5. Can one create an array where
each entry is a different compound type?

Thank you for your advice!

There is no direct mapping between a MATLAB cell array and an equivalent HDF5 data structure. I would suggest investigating some of the HDF5 low-level API functions to create a data structure that would mimic a collection of heterogeneous structures.

I hope this information helps.

···

-----Original Message-----
From: Hdf-forum [mailto:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of digitalriptide
Sent: Wednesday, December 31, 2014 12:49 AM
To: HDF Users Discussion List
Subject: [Hdf-forum] MATLAB Cell Array in HDF5?

Is there something with equivalent functionality to Matlab's cell array in HDF5? I am converting my code from Matlab output to HDF5 output, and I have a collection of heterogeneous structs that I would like to store in a a single array. I was previously outputting these to a cell array in Matlab, but I'm having trouble finding an example of an equivalent data structure in HDF5. Can one create an array where each entry is a different compound type?

Thank you for your advice!

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

The most recent versions of Matlab output to HDF5 files I believe, even though it may me called a .mat file. Create your cell arrays in Matlab, save to a file making certain you are using the new format, and then “browse” that file to see how it is stored.

HTH,

-roy

···

On Feb 13, 2015, at 10:29 AM, Ellen Johnson <Ellen.Johnson@mathworks.com> wrote:

There is no direct mapping between a MATLAB cell array and an equivalent HDF5 data structure. I would suggest investigating some of the HDF5 low-level API functions to create a data structure that would mimic a collection of heterogeneous structures.

I hope this information helps.

-----Original Message-----
From: Hdf-forum [mailto:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of digitalriptide
Sent: Wednesday, December 31, 2014 12:49 AM
To: HDF Users Discussion List
Subject: [Hdf-forum] MATLAB Cell Array in HDF5?

Is there something with equivalent functionality to Matlab's cell array in HDF5? I am converting my code from Matlab output to HDF5 output, and I have a collection of heterogeneous structs that I would like to store in a a single array. I was previously outputting these to a cell array in Matlab, but I'm having trouble finding an example of an equivalent data structure in HDF5. Can one create an array where each entry is a different compound type?

Thank you for your advice!

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn@noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.

The most recent versions of Matlab output to HDF5 files I believe, even
though it may me called a .mat file. Create your cell arrays in Matlab,
save to a file making certain you are using the new format, and then
“browse” that file to see how it is stored.

HTH,

-roy

This is a convenience but doesn't get you there all the way. Matlab will
save them as structures of arrays rather than an array of structures - in
HDF5 files with more path objects (groups) than you might expect. Most
applications would greatly prefer array of structures with a simple dataset
holding it. This example might be beneficial to you:
http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/matlab/HDF5_M_Examples/h5ex_t_cmpd.m
- recall matlab tries to impose column-major ordering everywhere even
though HDF5 specifications say row-major - this will matter if you try
saving anything 2+d. Anyway this makes you work with a structure of
arrays on the matlab side which I guess memory wise is exactly the type of
layout in Matlab that is compatible with HDF5's wants for array of
structures. That code can and should be made into some more generic
routines for doing this properly and arguably put into matlab's builtin hdf
HL routines so this stops being such a hassle for people... it shouldn't be
more complicated than save IMHO. The fieldnames function will list data in
the order you should use for H5T composition but it becomes challenging to
automatically guess at what is the "sample" index of ND arrays and
computing the size of each field instance.

-Jason

···

On Fri, Feb 13, 2015 at 10:48 AM, Roy Mendelssohn - NOAA Federal < roy.mendelssohn@noaa.gov> wrote:

On Feb 13, 2015, at 10:29 AM, Ellen Johnson <Ellen.Johnson@mathworks.com> > wrote:

> There is no direct mapping between a MATLAB cell array and an equivalent
HDF5 data structure. I would suggest investigating some of the HDF5
low-level API functions to create a data structure that would mimic a
collection of heterogeneous structures.
>
> I hope this information helps.
>
>
> -----Original Message-----
> From: Hdf-forum [mailto:hdf-forum-bounces@lists.hdfgroup.org] On Behalf
Of digitalriptide
> Sent: Wednesday, December 31, 2014 12:49 AM
> To: HDF Users Discussion List
> Subject: [Hdf-forum] MATLAB Cell Array in HDF5?
>
> Is there something with equivalent functionality to Matlab's cell array
in HDF5? I am converting my code from Matlab output to HDF5 output, and I
have a collection of heterogeneous structs that I would like to store in a
a single array. I was previously outputting these to a cell array in
Matlab, but I'm having trouble finding an example of an equivalent data
structure in HDF5. Can one create an array where each entry is a different
compound type?
>
> Thank you for your advice!
>
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> Hdf-forum@lists.hdfgroup.org
>
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
> Twitter: https://twitter.com/hdf5
>
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> Hdf-forum@lists.hdfgroup.org
> http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
> Twitter: https://twitter.com/hdf5

**********************
"The contents of this message do not reflect any position of the U.S.
Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn@noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
"the arc of the moral universe is long, but it bends toward justice" -MLK
Jr.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5