Main Content

cdflib.hyperGetVarData

Read hyperslab of data from variable

Syntax

data = cdflib.hyperGetVarData(cdfId,varNum,recSpec,dimSpec)
data = cdflib.hyperGetVarData(cdfId,varNum,recSpec)

Description

data = cdflib.hyperGetVarData(cdfId,varNum,recSpec,dimSpec) reads a hyperslab of data from a variable in the 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.

data = cdflib.hyperGetVarData(cdfId,varNum,recSpec) reads a hyperslab of data for a zero-dimensional variable in the Common Data Format (CDF) file.

Input Arguments

cdfId

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

varNum

Number identifying the variable containing the datum.

recSpec

Three-element array, [RSTART RCOUNT RSTRIDE], where RSTART, RCOUNT, and RSTRIDE are scalar values specifying the starting record, number of records to read, and the sampling interval or stride between records. Record numbers are zero-based.

dimSpec

Three-element cell array, {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.

Examples

Open the example CDF file, and then get all the data associated with a variable:

cdfId = cdflib.open("example.cdf");

% Determine number of records allocated for first variable in the file
maxRecNum = cdflib.getVarMaxWrittenRecNum(cdfId,0);

% Retrieve all data in records for variable
data = cdflib.hyperGetVarData(cdfId,0,[0 maxRecNum 1])
data =

   1.0e+13 *

    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
    6.3146
% Clean up
cdflib.close(cdfId)
clear cdfId

Tips

  • This function corresponds to the CDF library C API routine CDFhyperGetzVarData.

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

Version History

expand all