cdflib.deleteAttrgEntry
删除全局属性中的条目
语法
cdflib.deleteAttrgEntry(cdfId,attrNum,entryNum)
说明
cdflib.deleteAttrgEntry(cdfId,attrNum,entryNum)
删除常用数据格式 (CDF) 文件中某全局属性的条目。
输入参数
|
CDF 文件的标识符,通过调用 |
|
数值,用于标识属性。属性编号从 0 开始。该属性必须具有全局作用域。 |
|
数值,用于指定属性中的条目。条目编号从 0 开始。 |
示例
创建一个 CDF 文件,然后在该文件中创建一个全局属性。将值写入到该属性的一个条目,然后删除该条目。要运行此示例,当前必须位于可写文件夹中。
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