Main Content

matlab.io.hdf4.sd.writeChunk

Namespace: matlab.io.hdf4.sd

Write chunk to dataset

Syntax

writeChunk(sdsID,origin,dataChunk)

Description

writeChunk(sdsID,origin,dataChunk) writes an entire chunk of data to the dataset identified by sdsID. The origin input specifies the location of the chunk in chunking coordinates, not in dataset 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 dataset. 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);