Skip to Main Content Skip to Search
Product Documentation

cdflib.getVarData - Single value from record in variable

Syntax

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

Description

datum = cdflib.getVarData(cdfId,varNum,recNum,indices) returns a single value from a variable 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 these functions, 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

cdflib.getVarRecordData | cdflib.hyperGetVarData | cdflib.putVarData

Tutorials

  


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