Unknown error when using h5write

7 views (last 30 days)
Jack Bray
Jack Bray on 22 Mar 2021
Edited: Rashed Mohammed on 25 Mar 2021
I am trying to save data as HDF5 datasets and keep encountering this long error message when attempting to using h5write:
Warning: The following error was caught while executing 'H5ML.id' class destructor:
Error using hdf5lib2
The HDF5 library encountered an error and produced the following stack trace information:
H5FD_sec2_truncate unable to extend file properly
H5FD_truncate driver truncate request failed
H5F_dest low level truncate failed
H5F_try_close problems closing file
H5O_close problem attempting file close
H5D_close unable to release object header
H5I_dec_app_ref can't decrement ID ref count
H5I_dec_app_ref_always_close can't decrement ID ref count
H5Dclose can't decrement count on dataset ID
Error in H5ML.id/close (line 47)
H5ML.hdf5lib2(obj.callback, obj.identifier);
Error in H5ML.id/delete (line 36)
obj.close();
Error in h5write (line 46)
if nargin > 0
Error in HDFDataBase (line 28)
h5write('myh5file.h5',[dsname '_AR'],ar)
> In h5write (line 46)
In HDFDataBase (line 28)
I have no idea what I am doing wrong as it seems to work for some datasets, but not for others. This is what I am attempting to run:
path = 'D:\Exp1\group1\test1\';
d = dir([path '*.mat']);
for ii = 1:numel(d)
dsname = ['/Exp1/group1/test1/' d(ii).name(1:end-4)];
h5create('myh5file.h5',[dsname '_AR'],[200 43200])
h5create('myh5file.h5',[dsname '_RAW'],[800 43200])
h5create('myh5file.h5',[dsname '_ACCVAR'],[1 43200])
data = load([path d(ii).name]);
ar = [];
eeg = [];
acc = [];
for jj = 1:numel(data)
ar = horzcat(ar,data(jj).ARDATA);
raw = horzcat(raw,data(jj).RAWDATA);
acc = horzcat(acc,data(jj).ACCVAR);
end
% ar = 200x43200 double
% raw = 800x43200 double
% acc = 1x43200 double
h5write('myh5file.h5',[dsname '_AR'],ar)
h5write('myh5file.h5',[dsname '_EEG'],raw)
h5write('myh5file.h5',[dsname '_ACCVAR'],acc)
end
Any help would be greatly appreciated, thanks
  1 Comment
Rashed Mohammed
Rashed Mohammed on 25 Mar 2021
Edited: Rashed Mohammed on 25 Mar 2021
Hi Jack,
Can you share which MATLAB release and OS you are using? It would be helpful if you can share the files causing the issue so that we can reproduce it. Also, try the workaround mentioned here https://www.mathworks.com/support/bugreports/2414231 to see if it fixes the issue.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!