Skip to Main Content Skip to Search
Product Documentation

cdflib.putVarData - Write single value to variable

Syntax

cdflib.putVarData(cdfId,varNum,recNum,indices,datum)

Description

cdflib.putVarData(cdfId,varNum,recNum,indices,datum) writes a single value to a variable in a Common Data File (CDF) file.

Input Arguments

cdfId

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

varNum

Numeric value that identifies the variable to which you want to write the datum. Variable numbers are zero-based.

recNum

Numeric value that identifies the record to which you want to write the datum. Record numbers are zero-based.

dims

Dimension indices within the record. Dimension indices are zero-based.

datum

Data to be written to the variable.

Examples

Create a CDF, create a variable in the CDF and write data to the variable. To run this example, you must have write permission in the current folder.

cdfid = cdflib.create('your_file.cdf');

% Create a variable in the file.
varNum = cdflib.createVar(cdfid,'Grades','cdf_int1',1,[],true,[]);

% Write some data to the variable
cdflib.putVarData(cdfid,varNum,0,[],int8(98))

% Read the value from the variable.
datum = cdflib.getVarData(cdfid,varNum,0)

datum =

   98

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

References

This function corresponds to the CDF library C API routine CDFputzVarData. 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.getVarData | cdflib.getVarRecordData | cdflib.hyperGetVarData

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