Main Content

matlab.io.hdf4.sd.setCompress

Namespace: matlab.io.hdf4.sd

Set compression method of dataset

Syntax

setCompress(sdsID,comptype,compparm)

Description

setCompress(sdsID,comptype,compparm) sets the compression scheme for the specified dataset. The compression must be done before writing the dataset. Specify comptype as one of these values.

'none'No compression
'skphuff'Skipping Huffman compression
'deflate'GZIP compression
'rle'Run-length encoding

  • If comptype is 'none' or 'rle', then compparm need not be specified.

  • If comptype is 'skphuff', then compparm is the skipping size.

  • If comptype is 'deflate', then compparm is the deflate level, which must be between 0 and 9.

This function corresponds to the SDsetcompress function in the HDF library C API.

Examples

import matlab.io.hdf4.*
sdID = sd.start('myfile.hdf','create');
sdsID = sd.create(sdID,'temperature','double',[200 100]);
sd.setCompress(sdsID,'deflate',5);
data = rand(200,100);
sd.writeData(sdsID,[0 0],data);
sd.endAccess(sdsID);
sd.close(sdID);

See Also