필터 지우기
필터 지우기

Error writing array of class double to a HDF5 file

조회 수: 27 (최근 30일)
Enda Carroll
Enda Carroll 2019년 5월 23일
답변: Shivam Sardana 2019년 5월 30일
Hi
I am having trouble with the following code:
data = zeros(100);
for i = 1:100
for j = 1:100
data(i, j) = rand(1,1) + 1i*rand(1,1);
end
end
h5create("test.h5", "/test", size(data));
h5write("test.h5", "/test", data);
I am trying to write data of class double to a hdf5 file which I create but I recieve the following error
Warning: Conversion from double to datatype H5T_NATIVE_DOUBLE may clamp some values.
> In H5D.write (line 100)
In h5write (line 138)
Error using hdf5lib2
The class of input data must be double instead of double when the HDF5 class is H5T_IEEE_F64LE.
Error in H5D.write (line 100)
H5ML.hdf5lib2('H5Dwrite', varargin{:});
Error in h5write (line 138)
H5D.write(dataset_id,'H5ML_DEFAULT',memspace_id,filespace_id,dxpl,Data);
I have tried specifying the datatype when I create the hdf5 file but I recieve the same error message
h5create("test.h5", "/test", size(data), 'Datatype','double');
h5write("test.h5", "/test", data);
Thanks in advance

채택된 답변

Shivam Sardana
Shivam Sardana 2019년 5월 30일
Problem with your code is variable data is of complex double type. The error indicates there is a mismatch. To resolve this convert data from complex double type to double type.
data = zeros(100);
for i = 1:100
for j = 1:100
data(i, j) = rand(1,1) + 1i*rand(1,1);
end
end
data = real(data);
h5create("test.h5", "/test", size(data), 'Datatype','double');
h5write("test.h5", "/test", data);

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by