cdflib
与 CDF 库直接交互
说明
MATLAB® 提供对 CDF 库中数十种函数的直接访问。使用这些函数时,您可以读取和写入数据,创建变量、属性和项,以及利用 CDF 库的其他功能。要使用这些函数,必须熟悉 CDF C 接口。可以在 CDF 网站找到有关 CDF 的文档。
MATLAB 函数对应于 CDF 库的新标准接口中的函数。在大多数情况下,MATLAB 函数的语法类似于对应的 CDF 库函数的语法。要使用这些函数,必须使用包名称 cdflib
作为函数名称的前缀。例如,要使用 CDF 库函数打开现有的 CDF 文件,可以使用以下语法:
cdfid = cdflib.open('example.cdf');
下表列出了 MATLAB CDF 库程序包中的所有函数,并按类别分组。
库信息
cdflib.getConstantNames | Names of Common Data Format (CDF) library constants |
cdflib.getConstantValue | Numeric value corresponding to Common Data Format (CDF) library constant |
cdflib.getFileBackward | Return current backward compatibility mode setting |
cdflib.getLibraryCopyright | Copyright notice of Common Data Format (CDF) library |
cdflib.getLibraryVersion | Library version and release information |
cdflib.getValidate | Library validation mode |
cdflib.setFileBackward | Set backward compatibility mode |
cdflib.setValidate | Specify library validation mode |
文件操作
cdflib.close | Close Common Data Format (CDF) file |
cdflib.create | Create Common Data Format (CDF) file |
cdflib.delete | Delete existing Common Data Format (CDF) file |
cdflib.getCacheSize | Number of cache buffers used |
cdflib.getChecksum | Checksum mode |
cdflib.getCompression | Compression settings |
cdflib.getCompressionCacheSize | Number of compression cache buffers |
cdflib.getCopyright | Copyright notice in Common Data Format (CDF) file |
cdflib.getFormat | Format of Common Data Format (CDF) file |
cdflib.getMajority | Majority of variables |
cdflib.getName | Name of Common Data Format (CDF) file |
cdflib.getReadOnlyMode | Read-only mode |
cdflib.getStageCacheSize | Number of cache buffers for staging |
cdflib.getVersion | Common Data Format (CDF) library version and release information |
cdflib.inquire | Basic characteristics of Common Data Format (CDF) file |
cdflib.open | Open existing Common Data Format (CDF) file |
cdflib.setCacheSize | Specify number of dotCDF cache buffers |
cdflib.setChecksum | Specify checksum mode |
cdflib.setCompression | Specify compression settings |
cdflib.setCompressionCacheSize | Specify number of compression cache buffers |
cdflib.setFormat | Specify format of Common Data Format (CDF) file |
cdflib.setMajority | Specify majority of variables |
cdflib.setReadOnlyMode | Specify read-only mode |
cdflib.setStageCacheSize | Specify number of staging cache buffers for Common Data Format (CDF) file |
变量
cdflib.closeVar | Close specified variable from multifile format Common Data Format (CDF) file |
cdflib.createVar | Create new variable |
cdflib.deleteVar | Delete variable |
cdflib.deleteVarRecords | Delete range of records from variable |
cdflib.getVarAllocRecords | Number of records allocated for variable |
cdflib.getVarBlockingFactor | Blocking factor for variable |
cdflib.getVarCacheSize | Number of multifile cache buffers |
cdflib.getVarCompression | Information about compression used by variable |
cdflib.getVarData | Single value from record in variable |
cdflib.getVarMaxAllocRecNum | Maximum allocated record number for variable |
cdflib.getVarMaxWrittenRecNum | Maximum written record number for variable |
cdflib.getVarName | Variable name, given variable number |
cdflib.getVarNum | Variable number, given variable name |
cdflib.getVarNumRecsWritten | Number of records written to variable |
cdflib.getVarPadValue | Pad value for variable |
cdflib.getVarRecordData | Entire record for variable |
cdflib.getVarReservePercent | Compression reserve percentage for variable |
cdflib.getVarSparseRecords | Information about how variable handles sparse records |
cdflib.getVarsMaxWrittenRecNum | Maximum written record number for CDF file |
cdflib.hyperGetVarData | Read hyperslab of data from variable |
cdflib.hyperPutVarData | Write hyperslab of data to variable |
cdflib.inquireVar | Information about variable |
cdflib.putVarData | Write single value to variable |
cdflib.putVarRecordData | Write entire record to variable |
cdflib.renameVar | Rename existing variable |
cdflib.setVarAllocBlockRecords | Specify range of records to be allocated for variable |
cdflib.setVarBlockingFactor | Specify blocking factor for variable |
cdflib.setVarCacheSize | Specify number of multi-file cache buffers for variable |
cdflib.setVarCompression | Specify compression settings used with variable |
cdflib.setVarInitialRecs | Specify initial number of records written to variable |
cdflib.setVarPadValue | Specify pad value used with variable |
cdflib.setVarReservePercent | Specify reserve percentage for variable |
cdflib.setVarSparseRecords | Specify how variable handles sparse records |
cdflib.setVarsCacheSize | Specify number of cache buffers used for all variables |
属性
cdflib.createAttr | Create attribute |
cdflib.deleteAttr | Delete attribute |
cdflib.deleteAttrEntry | Delete attribute entry |
cdflib.deleteAttrgEntry | Delete entry in global attribute |
cdflib.getAttrEntry | Value of entry in attribute with variable scope |
cdflib.getAttrMaxEntry | Number of last entry for variable attribute |
cdflib.getAttrMaxgEntry | Number of last entry for global attribute |
cdflib.getAttrName | Name of attribute, given attribute number |
cdflib.getAttrNum | Attribute number, given attribute name |
cdflib.getAttrScope | Scope of attribute |
cdflib.getAttrgEntry | Value of entry in global attribute |
cdflib.getNumAttrEntries | Number of entries for attribute with variable scope |
cdflib.getNumAttrgEntries | Number of entries for attribute with global scope |
cdflib.getNumAttributes | Number of attributes with variable scope |
cdflib.getNumgAttributes | Number of attributes with global scope |
cdflib.inquireAttr | Information about attribute |
cdflib.inquireAttrEntry | Information about entry in attribute with variable scope |
cdflib.inquireAttrgEntry | Information about entry in attribute with global scope |
cdflib.putAttrEntry | Write value to entry in attribute with variable scope |
cdflib.putAttrgEntry | Write value to entry in attribute with global scope |
cdflib.renameAttr | Rename existing attribute |
工具函数
cdflib.breakdownTT2000 | Convert CDF_TIME_TT2000 timestamp to time
components |
cdflib.computeEpoch | Convert time value to CDF_EPOCH value |
cdflib.computeEpoch16 | Convert time value to CDF_EPOCH16 value |
cdflib.computeTT2000 | Convert time components to CDF_TIME_TT2000
timestamp |
cdflib.epoch16Breakdown | Convert CDF_EPOCH16 value to time value |
cdflib.epochBreakdown | Convert CDF_EPOCH value into time value |
局限性
CDF 文件不支持采用非 ASCII 字符编码的输入。变量名称、属性名称、变量值和属性值必须采用 7 位 ASCII 编码。尝试写入采用非 ASCII 字符编码的输入将发生错误或者导致数据中包含损坏的字符。