Main Content

cdflib.deleteAttr

Delete attribute

Syntax

cdflib.deleteAttr(cdfId,attrNum)

Description

cdflib.deleteAttr(cdfId,attrNum) deletes the specified attribute from the CDF file.

cdfId identifies the Common Data Format (CDF) file.attrNum is a numeric identifier that specifies the attribute. Attribute numbers are zero-based.

Examples

Create a CDF file, and then create an attribute in the file. Then delete the attribute. To run this example, you must be in a writable folder.

cdfId = cdflib.create("your_file.cdf");

% Create attribute
attrNum = cdflib.createAttr(cdfId,"Purpose","global_scope");

% Prove it exists
attrNum = cdflib.getAttrNum(cdfId,"Purpose")
attrNum =

     0
% Delete the attribute
cdflib.deleteAttr(cdfId,attrNum)

% Prove it no longer exists
try
    attrNum = cdflib.getAttrNum(cdfId,"Purpose");
catch
    warning("No attribute named ""Purpose""")
end
Warning: No attribute named "Purpose"
% Clean up
cdflib.delete(cdfId)
clear cdfId

References

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

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