This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Single value from record in variable


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


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


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


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


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.


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


Value of the specified record.


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

cdfid ='example.cdf');

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


ans =


% 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 =


% 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 =


% Clean up.
clear cdfid

Related Examples


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 website.

For copyright information, see the cdfcopyright.txt file.

Was this topic helpful?