0

I'm saving large data array to mat file.

m = matfile('data.mat','writable',true);
m.X(1000,1000,10,50000) = nan(1,'single');
for ii = 1 : 50000
  % do some computation
  m.X(1:1000,1:1000,1:10,ii) = Y;
end

How can I set ChunkSize of X to [1000,1000,1,1]?

wsdzbm
  • 3,096
  • 3
  • 25
  • 28
  • Don't think you can influence it. What is your goal behind changing the chunksize? – Daniel Feb 05 '20 at 20:46
  • @Daniel because the matfile will be huge and in the postprocessing, I need to read them frame by frame. – wsdzbm Feb 08 '20 at 02:03

1 Answers1

0

You can't use the matfile command, but you use the HDF5 api. Since matfiles v7.3 use the HDF5 format, i guess it should also work on the reading side for you? Here is a small example from the documentation:

h5create('myfile.h5','/DS3',[20 Inf],'ChunkSize',[5 5]);
for j = 1:10
      data = j*ones(20,1);
      start = [1 j];
      count = [20 1];
      h5write('myfile.h5','/DS3',data,start,count);
end
h5disp('myfile.h5');

Source of the example

Daniel
  • 36,610
  • 3
  • 36
  • 69