This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Define compression parameters for NetCDF variable




netcdf.defVarDeflate(ncid,varid,shuffle,deflate,deflateLevel) sets the compression parameters for the NetCDF variable specified by varid in the location specified by ncid.

Input Arguments


Identifier of NetCDF file, returned by netcdf.create or, or of a NetCDF group, returned by netcdf.defGrp.


Identifier of a NetCDF variable, returned by netcdf.defVar.


Boolean value. To turn on the shuffle filter, set this argument to true. The shuffle filter can assist with the compression of integer data by changing the byte order in the data stream.


Boolean value. To turn on compression, set this argument to true and set the deflateLevel argument to the desired compression level.


Numeric value between 0 and 9 specifying the amount of compression, where 0 is no compression and 9 is the most compression.


This example create a variable with dimensions [1800 3600] and a compression level of 5. This results in a chunked layout that is a 10-by-10 grid. Use netcdf.defVarChunking to define your own chunking, otherwise netcdf.defVarDeflate uses the library default values.

ncid = netcdf.create('','NETCDF4');
latdimid = netcdf.defDim(ncid,'lat',1800);
londimid = netcdf.defDim(ncid,'col',3600);
varid = netcdf.defVar(ncid,'earthgrid','double',[latdimid londimid]);
netcdf.defVarChunking(ncid,varid,'CHUNKED',[180 360]);


This function corresponds to the nc_def_var_deflate function in the netCDF library C API.

For copyright information, read the netcdfcopyright.txt and mexnccopyright.txt files.