Main Content

本页面提供的是上一版软件的文档。当前版本中已删除对应的英文页面。

cdflib

与 CDF 库直接交互

说明

MATLAB® 提供对 CDF 库中数十种函数的直接访问。使用这些函数时,您可以读取和写入数据,创建变量、属性和项,以及利用 CDF 库的其他功能。要使用这些函数,必须熟悉 CDF C 接口。可以在 CDF 网站找到有关 CDF 的文档。

MATLAB 函数对应于 CDF 库的新标准接口中的函数。在大多数情况下,MATLAB 函数的语法类似于对应的 CDF 库函数的语法。要使用这些函数,必须使用包名称 cdflib 作为函数名称的前缀。例如,要使用 CDF 库函数打开现有的 CDF 文件,可以使用以下语法:

cdfid = cdflib.open("example.cdf");

下表列出了 MATLAB CDF 库程序包中的所有函数,并按类别分组。

库信息

cdflib.getConstantNamesNames of Common Data Format (CDF) library constants
cdflib.getConstantValueNumeric value corresponding to Common Data Format (CDF) library constant
cdflib.getLibraryCopyrightCopyright notice of Common Data Format (CDF) library
cdflib.getLibraryVersionLibrary version and release information
cdflib.getValidateLibrary validation mode
cdflib.setValidateSpecify library validation mode

文件操作

cdflib.closeClose Common Data Format (CDF) file
cdflib.createCreate Common Data Format (CDF) file
cdflib.deleteDelete Common Data Format (CDF) file
cdflib.getCacheSizeNumber of cache buffers
cdflib.getChecksumChecksum mode
cdflib.getCompressionCompression settings
cdflib.getCompressionCacheSizeNumber of compression cache buffers
cdflib.getCopyrightCopyright notice in Common Data Format (CDF) file
cdflib.getFormatFormat of Common Data Format (CDF) file
cdflib.getMajorityMajority of variables
cdflib.getNameName of Common Data Format (CDF) file
cdflib.getReadOnlyModeRead-only mode
cdflib.getStageCacheSizeNumber of cache buffers for staging
cdflib.getVersionCommon Data Format (CDF) library version and release information
cdflib.inquireInformation about Common Data Format (CDF) file
cdflib.openOpen Common Data Format (CDF) file
cdflib.setCacheSizeSpecify number of dotCDF cache buffers
cdflib.setChecksumSpecify checksum mode
cdflib.setCompressionSpecify compression settings
cdflib.setCompressionCacheSizeSpecify number of compression cache buffers
cdflib.setFormatSpecify format of Common Data Format (CDF) file
cdflib.setMajoritySpecify majority of variables
cdflib.setReadOnlyModeSpecify read-only mode
cdflib.setStageCacheSizeSpecify number of staging cache buffers for Common Data Format (CDF) file

变量

cdflib.closeVarClose specified variable from multifile format Common Data Format (CDF) file
cdflib.createVarCreate new variable
cdflib.deleteVarDelete variable
cdflib.deleteVarRecordsDelete range of records from variable
cdflib.getVarAllocRecordsNumber of records allocated for variable
cdflib.getVarBlockingFactorBlocking factor for variable
cdflib.getVarCacheSizeNumber of multifile cache buffers
cdflib.getVarCompressionInformation about compression used by variable
cdflib.getVarDataSingle value from record in variable
cdflib.getVarMaxAllocRecNumMaximum allocated record number for variable
cdflib.getVarMaxWrittenRecNumMaximum written record number for variable
cdflib.getVarNameVariable name, given variable number
cdflib.getVarNumVariable number, given variable name
cdflib.getVarNumRecsWrittenNumber of records written to variable
cdflib.getVarPadValuePad value for variable
cdflib.getVarRecordDataEntire record for variable
cdflib.getVarReservePercentCompression reserve percentage for variable
cdflib.getVarSparseRecordsInformation about how variable handles sparse records
cdflib.getVarsMaxWrittenRecNumMaximum written record number for CDF file
cdflib.hyperGetVarDataRead hyperslab of data from variable
cdflib.hyperPutVarDataWrite hyperslab of data to variable
cdflib.inquireVarInformation about variable
cdflib.putVarDataWrite single value to variable
cdflib.putVarRecordDataWrite entire record to variable
cdflib.renameVarChange name of variable
cdflib.setVarAllocBlockRecordsSpecify range of records to be allocated for variable
cdflib.setVarBlockingFactorSpecify blocking factor for variable
cdflib.setVarCacheSizeSpecify number of multifile cache buffers for variable
cdflib.setVarCompressionSpecify compression settings used with variable
cdflib.setVarInitialRecsSpecify initial number of records written to variable
cdflib.setVarPadValueSpecify pad value used with variable
cdflib.setVarReservePercentSpecify reserve percentage for variable
cdflib.setVarSparseRecordsSpecify how variable handles sparse records
cdflib.setVarsCacheSizeSpecify number of cache buffers used for all variables

属性

cdflib.createAttrCreate attribute
cdflib.deleteAttrDelete attribute
cdflib.deleteAttrEntryDelete entry from attribute with variable scope
cdflib.deleteAttrgEntryDelete entry from attribute with global scope
cdflib.getAttrEntryValue of entry in attribute with variable scope
cdflib.getAttrMaxEntryNumber of last entry for variable attribute
cdflib.getAttrMaxgEntryNumber of last entry for global attribute
cdflib.getAttrNameAttribute name, given attribute number
cdflib.getAttrNumAttribute number, given attribute name
cdflib.getAttrScopeScope of attribute
cdflib.getAttrgEntryValue of entry in global attribute
cdflib.getNumAttrEntriesNumber of entries for attribute with variable scope
cdflib.getNumAttrgEntriesNumber of entries for attribute with global scope
cdflib.getNumAttributesNumber of attributes with variable scope
cdflib.getNumgAttributesNumber of attributes with global scope
cdflib.inquireAttrInformation about attribute
cdflib.inquireAttrEntryInformation about entry in attribute with variable scope
cdflib.inquireAttrgEntryInformation about entry in attribute with global scope
cdflib.putAttrEntryWrite value to entry in attribute with variable scope
cdflib.putAttrgEntryWrite value to entry in attribute with global scope
cdflib.renameAttrChange name of attribute

工具函数

cdflib.breakdownTT2000Convert CDF_TIME_TT2000 timestamp to time components
cdflib.computeEpochConvert time value to CDF_EPOCH value
cdflib.computeEpoch16Convert time value to CDF_EPOCH16 value
cdflib.computeTT2000Convert time components to CDF_TIME_TT2000 timestamp
cdflib.epoch16BreakdownConvert CDF_EPOCH16 value to time value
cdflib.epochBreakdownConvert CDF_EPOCH value to time value

局限性

  • CDF 文件不支持采用非 ASCII 字符编码的输入。变量名称、属性名称、变量值和属性值必须采用 7 位 ASCII 编码。尝试写入采用非 ASCII 字符编码的输入将发生错误或者导致数据中包含损坏的字符。