Main Content

cdflib.putAttrgEntry

Write value to entry in attribute with global scope

Syntax

cdflib.putAttrgEntry(cdfId,attrNum,entryNum,cdfDataType,entryVal)

Description

cdflib.putAttrgEntry(cdfId,attrNum,entryNum,cdfDataType,entryVal) writes a value to a global attribute entry 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.

attrNum

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

entryNum

Number identifying entry. Entry numbers are zero-based.

CDFdatatype

Data type of the attribute entry, specified as one of the following character vectors or string scalars, or its numeric equivalent.

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

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

'CDF_INT1'1-byte, signed integer.
'CDF_UCHAR'

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

entryVal

Data to be written to global attribute entry.

Examples

Create a CDF and create a global attribute 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 global or variable attributes
info = cdflib.inquire(cdfId)
info = 

  struct with fields:

     encoding: 'IBMPC_ENCODING'
     majority: 'ROW_MAJOR'
       maxRec: -1
      numVars: 0
    numvAttrs: 0
    numgAttrs: 0
% Create a global attribute in the file.
attrNum = cdflib.createAttr(cdfId,"Purpose","global_scope");

% Write a value to an entry for the global attribute
cdflib.putAttrgEntry(cdfId,attrNum,0,"CDF_CHAR","My Test")

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

    'My Test'
% Clean up
cdflib.delete(cdfId)
clear cdfId

References

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

To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.