Main Content


Write hyperslab of data to variable




cdflib.hyperPutVarData(cdfId,varNum,recSpec,dimSpec,data) writes a hyperslab of data to a variable in a Common Data Format (CDF) file. Hyper access allows more than one value to be read from or written to a variable with a single call to the CDF library.

Input Arguments


Identifier of a CDF file, returned by a call to cdflib.create or


Specifies the variable containing the datum.


Three-element array described by [RSTART RCOUNT RSTRIDE], where RSTART, RCOUNT, and RSTRIDE are scalar values giving the start, number of records, and sampling interval (or stride) between records. Record indices are zero-based.


Three-element cell array described by {DSTART DCOUNT DSTRIDE}, where DSTART, DCOUNT, and DSTRIDE are n-element vectors that describe the start, number of values along each dimension, and sampling interval along each dimension. If the hyperslab has zero dimensions, you can omit this parameter. Dimension indices are zero-based.


Data to write to the variable.


Create a CDF, create a variable, and then write a slab of data to the variable. To run this example, you must be in a writable folder.

cdfId = cdflib.create("your_file.cdf");

% Create a variable in the file
varNum = cdflib.createVar(cdfId,"Grades","cdf_int1",1,[],true,[]);

% Write data to the variable
cdflib.hyperPutVarData(cdfId,varNum,[0 1 1],{0 1 1},int8(98))

%Clean up
clear cdfId


This function corresponds to the CDF library C API routine CDFhyperzPutVarData.

To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.