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.


Write value to entry in attribute with variable scope




cdflib.putAttrEntry(cdfId,attrNum,entryNum,CDFDataType,entryVal) writes a value to an attribute entry in a Common Data Format (CDF) file.

Input Arguments


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


Number identifying attribute. The attribute must have variable scope. Attribute numbers are zero-based.


Number identifying entry. Entry numbers are zero-based.


One of the following text character vectors, or its numeric equivalent, that specify the data type of the attribute entry.

CDF Data TypeMATLAB® Equivalent
'CDF_BYTE'1-byte, signed integer

1 byte, signed character data type that maps to the MATLAB char class

'CDF_INT1'1-byte, signed integer.

1 byte, unsigned character data type that maps to the MATLAB uint8 class

'CDF_UINT1'1-byte, unsigned integer
'CDF_INT2'2-byte, signed integer
'CDF_UINT2'2-byte, unsigned integer.
'CDF_INT4'4-byte, signed integer
'CDF_UINT4'4-byte, unsigned integer
'CDF_FLOAT'4-byte, floating point
'CDF_REAL4'4-byte, floating point
'CDF_REAL8'8-byte, floating point.
'CDF_DOUBLE'8-byte, floating point
'CDF_EPOCH'8-byte, floating point
'CDF_EPOCH16'two 8-byte, floating point


Data to be written to attribute entry.


Create a CDF and create an attribute with variable scope in the file. Write a value to an entry in the attribute. To run this example, you must be in a writable folder.

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

% Initially the file contains no attributes, global or variable.
info = cdflib.inquire(cdfid)

info = 

     encoding: 'IBMPC_ENCODING'
     majority: 'ROW_MAJOR'
       maxRec: -1
      numVars: 0
    numvAttrs: 0
    numgAttrs: 0

% Create an attribute of variable scope in the file.
attrNum = cdflib.createAttr(cdfid,'Another Attribute','variable_scope');

% Write a value to an entry for the attribute
cdflib.putAttrEntry(cdfid,attrNum,0,'CDF_CHAR','My Variable Attribute Test');

% Get the value of the global attribute entry
value = cdflib.getAttrEntry(cdfid,attrNum,0)

value =

My Variable Attribute Test

% Clean up

clear cdfid


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

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?