Create HDF5 file from multidimensional data
조회 수: 15 (최근 30일)
이전 댓글 표시
Let's assume I have a specific type of multidimensional data that is of shape 256*256*50. I have 7000 samples of this multideimensional data. How can I create an HDF5 file in MATLAB from this dataset? Since my dataset (256*256*50*7000) exceeds the available system memory I think my only option is to write the HDF5 data inside a for loop. Here is a sample code that returns an error "The amount of data to be written does not match the size of the HDF5 dataset.":
clear; close all; clc;
h5create('myfile.h5','/myDataset',[256 256 50 7000],'Datatype','single')
h5disp('myfile.h5')
I = imread('cameraman.tif');
for i=1:50
mydata(:,:,i) = I;
end
for i=1:7000
h5write('myfile.h5', '/myDataset', mydata)
end
댓글 수: 2
Radek Chrapkiewicz
2020년 6월 14일
You have to specify additionally count and stride within h5write.
For example:
h5create('test.h5','/1',[10,10,Inf],'ChunkSize',[10,10,1])
h5write('test.h5','/1',rand(10))
Yields the following error:
Error using h5write (line 115)
The amount of data to be written does not match the size of the HDF5 dataset.
But if you specify additionally start and count, you can make it:
h5write('test.h5','/1',rand(10),[1,1,1],[10,10,1])
h5write('test.h5','/1',rand(10),[1,1,2],[10,10,1])
h5write('test.h5','/1',rand(10),[1,1,3],[10,10,1])
data=h5read('test.h5','/1');
size(data)
답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!