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
|
Identifier of a CDF file, returned by a call to |
|
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. |
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); numVars = info.numVars
numVars = 6
% Determine if the first variable has dimensions
varnum = 0;
varinfo = cdflib.inquireVar(cdfId,varnum);
vardims = varinfo.dims
vardims = []
% Get first data record from variable, without specifying dimensions
recnum = 0;
datum = cdflib.getVarData(cdfId,varnum,recnum)
datum = 6.3146e+13
% Get dimensions of another variable in file
varnum = 3;
varinfo = cdflib.inquireVar(cdfId,varnum);
vardims = varinfo.dims
vardims = 4 2 2
% Retrieve the first datum in the record (indices are zero-based)
datum = cdflib.getVarData(cdfId,varnum,recnum,[0 0 0])
datum = 30
% Clean up cdflib.close(cdfId) clear cdfId
Tips
This function corresponds to the CDF library C API routine
CDFgetzVarData
.To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.