Documentation Center

  • Trial Software
  • Product Updates

cdflib.getVarData

Single value from record in variable

Syntax

datum = cdflib.getVarData(cdfId,varNum,recNum,indices)
datum = cdflib.getVarData(cdfId,varNum,recNum)

Description

datum = cdflib.getVarData(cdfId,varNum,recNum,indices) returns a single value from a variable in a Common Data Format (CDF) file.

datum = cdflib.getVarData(cdfId,varNum,recNum) returns a single value from a variable with no dimensions in a Common Data Format (CDF) file.

Input Arguments

cdfId

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

varNum

Numeric value identifying the variable containing the datum. Variable numbers are zero-based.

recNum

Numeric value identifying the location of the datum in the variable. In CDF terminology, this is called the record number. Record numbers are zero-based.

indices

Array of dimension indices within the record. Dimension indices are zero-based. If the variable has no dimensions, you can omit this parameter.

Output Arguments

datum

Value of the specified record.

Examples

Open the example CDF file and retrieve data associated with a variable:

cdfid = cdflib.open('example.cdf');

% Determine how many variables are in the file.
info = cdflib.inquire(cdfid);

info.numVars

ans =

  5

% Determine if the first variable has dimensions.
varinfo = cdflib.inquireVar(cdfid,0);
vardims = varinfo.dims
vardims =

  []

% Get data from variable, without specifying dimensions.
datum = cdflib.getVarData(cdfid, varnum, recnum) 

datum =

  6.3146e+013

% Get dimensions of another variable in file.
varinfo = cdflib.inquireVar(cdfid,3);
vardims = varinfo.dims
vardims =

  [4 2 2]

% Retrieve the first datum in the record. Indices are zero-based.
datum = cdflib.getVarData(cdfId,3,0,[0 0 0])

info =

    30

% Clean up.
cdflib.close(cdfid);
clear cdfid

References

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

To use this function, you must be familiar with the CDF C interface. Read the CDF documentation at the CDF Web site.

For copyright information, see the cdfcopyright.txt file.

See Also

| |

Tutorials

Was this topic helpful?