Thursday, February 5, 2009

HDF5 in Matlab!!!

Behold: last versions of Matlabsupport HDF5!
there are only 3 (!) upper level functions which can do a lot: hdf5 - read/write/info
plus : all the low level functions are also available (via wrappers)! (there are some Matlab-specific as well)

BUT:

don't forget to wrap read/write in try/catch statements since
they cannot delete/overwrite existingentries in a file and
thus will throw an exception on such an attempt...

moreover, hdf5read can be used to read attributes,
BUT consider the following innocent command: hdf5read(file, '/1');
it either reads the dataset '1' located in the root group OR
the attribute '1' of the root group! It's just tooo ambiguous for me!



% my very ML confusing example:
hdf5write('a.h5', struct('Location', '/', 'Name', '1'), 'What is right?', ...
struct('AttachedTo', '/', 'Name', '1', 'AttachType', 'group'), 'And what is wrong?');

% let's read attribute '1' of the root:

% naiive:
i = hdf5read('a.h5', '/1');

i.Data
% gives 'What is right?' to me, which is not what i wanted!

% and the attribute must be read as follows:
info = hdf5info('a.h5', 'ReadAttributes', true);

info.GroupHierarchy.Attributes.Value.Data
% gives 'And what is wrong?' to me

No comments:

Post a Comment