Skip to Main Content Skip to Search
Product Documentation

cdflib.putAttrEntry - Write value to entry in attribute with variable scope

Syntax

cdflib.putAttrEntry(cdfId,attrNum,entryNum,CDFDataType,entryVal)

Description

cdflib.putAttrEntry(cdfId,attrNum,entryNum,CDFDataType,entryVal) writes a value to an 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. The attribute must have variable scope. Attribute numbers are zero-based.

entryNum

Number identifying entry. Entry numbers are zero-based.

CDFdatatype

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

CDF Data TypeMATLAB Equivalent
CDF_BYTE1-byte, signed integer
CDF_CHAR1 byte, signed character data type that maps to the MATLABchar class
CDF_INT11-byte, signed integer.
CDF_UCHAR1 byte, unsigned character data type that maps to the MATLABuint8 class
CDF_UINT11-byte, unsigned integer
CDF_INT22-byte, signed integer
CDF_UINT22-byte, unsigned integer.
CDF_INT44-byte, signed integer
CDF_UINT44-byte, unsigned integer
CDF_FLOAT4-byte, floating point
CDF_REAL44-byte, floating point
CDF_REAL88-byte, floating point.
CDF_DOUBLE8-byte, floating point
CDF_EPOCH8-byte, floating point
CDF_EPOCH16two 8-byte, floating point

entryVal

Data to be written to attribute entry.

Examples

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
cdflib.delete(cdfid);

clear cdfid

References

This function corresponds to the CDF library C API routine CDFputAttrzEntry. 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.getAttrEntry | cdflib.getAttrgEntry | cdflib.getConstantValue | cdflib.putAttrgEntry

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