Main Content

cdflib.deleteAttrgEntry

Delete entry in global attribute

Syntax

cdflib.deleteAttrgEntry(cdfId,attrNum,entryNum)

Description

cdflib.deleteAttrgEntry(cdfId,attrNum,entryNum) deletes an entry from a global attribute 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

Numeric value that identifies the attribute. Attribute numbers are zero-based. The attribute must have global scope.

entryNum

Numeric value that specifies the entry in the attribute. Entry numbers are zero-based.

Examples

Create a CDF and create a global attribute in the file. Write a value to an entry for the attribute and then delete the entry. 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 an attribute with global scope in the file
attrNum = cdflib.createAttr(cdfId,"my_global_attr","global_scope");

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

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

    'My global attr'
% Delete the entry
cdflib.deleteAttrgEntry(cdfId,attrNum,0)

% Now try to view the value of the entry
try
    value = cdflib.getAttrgEntry(cdfId,attrNum,0)
catch
    warning("No attribute associated with this variable")
end
Warning: No attribute associated with this variable
% Clean up
cdflib.delete(cdfId)
clear cdfId

References

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

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