Skip to Main Content Skip to Search
Product Documentation

netcdf.defVarDeflate - Define compression parameters for NetCDF variable

Syntax

netcdf.defVarDeflate(ncid,varid,shuffle,deflate,deflateLevel)

Description

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

ncid

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

varid

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

shuffle

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.

deflate

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

deflateLevel

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

Examples

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.

ncid = netcdf.create('myfile.nc','NETCDF4');
latdimid = netcdf.defDim(ncid,'lat',1800);
londimid = netcdf.defDim(ncid,'col',3600);
varid = netcdf.defVar(ncid,'earthgrid','double',[latdimid londimid]);
netcdf.defVarDeflate(ncid,varid,true,true,5);
netcdf.close(ncid);

References

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.

See Also

netcdf | netcdf.inqVarDeflate

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS