Main Content

netcdf.defVarFill

Define fill parameters for netCDF variable

    Description

    example

    netcdf.defVarFill(ncid,varid,noFillMode,fillValue) sets the fill parameters for a variable in a netCDF file or group. varid identifies the variable and ncid identifies the netCDF file or group.

    For netCDF-4 files, you can only specify fill values when the netCDF is in definition mode. For netCDF files in classic and 64-bit offset modes, you can turn no-fill mode on and off at any time.

    Examples

    collapse all

    This example creates a netCDF-4 file and defines a fill value for a variable.

    ncid = netcdf.create("myfile.nc","NETCDF4");
    dimid = netcdf.defDim(ncid,"latitude",180);
    varid = netcdf.defVar(ncid,"latitude","double",dimid);
    netcdf.defVarFill(ncid,varid,false,-999);
    netcdf.close(ncid);

    Input Arguments

    collapse all

    Identifier of a netCDF file, returned by netcdf.create or netcdf.open, or of a netCDF group, returned by netcdf.defGrp, specified as a nonnegative integer scalar.

    Data Types: double

    Identifier of netCDF variable, returned by netcdf.defVar, specified as a nonnegative integer scalar.

    Data Types: double

    Fill value mode for netCDF variable, set to true or false. When set to true, netcdf.defVarFill turns off the use of fill values for the variable, which is helpful in high performance applications. When set to true, netcdf.defVarFill ignores the value of the fillValue argument. To use the fill value, set the value to false.

    Note

    You must not specify noFillMode as true when writing data of type NC_STRING to netCDF-4 files.

    Data Types: logical

    Fill value to use in the netCDF variable, specified as a scalar.

    Note

    The data type of fillValue must be same as the data type of the netCDF variable.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Tips

    • This function corresponds to the nc_def_var_fill function in the netCDF library C API.

    Version History

    Introduced in R2010b