Main Content

matlab.io.hdf4.sd.writeChunk

Package: matlab.io.hdf4.sd

Write chunk to data set

Syntax

writeChunk(sdsID,origin,dataChunk)

Description

writeChunk(sdsID,origin,dataChunk) writes an entire chunk of data to the data set identified by sdsID. The origin input specifies the location of the chunk in chunking coordinates, not in data set coordinates.

This function corresponds to the SDwritechunk function in the HDF library C API, but because MATLAB® uses FORTRAN-style ordering, the origin parameter is reversed with respect to the C library API.

Examples

Write to a 2D chunked and compressed data set. The chunked layout constitutes a 10-by-5 grid.

import matlab.io.hdf4.*
sdID = sd.start('myfile.hdf','create');
sdsID = sd.create(sdID,'temperature','double',[100 50]);
sd.setChunk(sdsID,[10 10],'deflate',5);
for j = 0:9
    for k = 0:4
        origin = [j k];
        data = (1:100) + k*1000 + j*10000;
        data = reshape(data,10,10);
        sd.writeChunk(sdsID,origin,data);
    end
end
sd.endAccess(sdsID);
sd.close(sdID);