本页面提供的是上一版软件的文档。当前版本中已删除对应的英文页面。
ncreadatt
读取 NetCDF 数据源中的属性值
说明
示例
读取全局属性
读取与变量相关联的属性
读取变量的关联属性。
scale_factor = ncreadatt("example.nc","temperature","scale_factor")
scale_factor = 1.8000
读取与组相关联的属性
读取与组相关联的属性。此示例仅适用于 NetCDF-4 格式文件。
desc_value = ncreadatt("example.nc","/grid2","description")
desc_value = 'This is another group attribute.'
输入参数
source
— NetCDF 数据源的名称
字符串标量 | 字符向量
NetCDF 数据源的名称,指定为字符串标量或字符向量。source
参数可以是以下值之一:
本地 NetCDF 源的路径
远程 OPeNDAP NetCDF 数据源的 OPeNDAP URL
远程 NetCDF 源的 HTTP URL,在 URL 的末尾附加
#mode=bytes
以支持字节范围读取注意
字节范围读取比从其他来源读取要慢。有关字节范围读取的更多详细信息,请参阅 NetCDF 文档。
示例: "myNetCDFfile.nc"
location
— 组或变量的位置
字符串标量 | 字符向量
NetCDF 数据源中组或变量的位置,指定为字符串标量或字符向量。要读取全局属性,请将 location
设置为 '/'
(正斜杠)。
attname
— 属性名称
字符串标量 | 字符向量
要读取的属性名称,指定为字符串标量或字符向量。
详细信息
NetCDF 到 MATLAB 数据类型的转换
NetCDF 相关的 MATLAB 函数根据此表自动选择与 NetCDF 数据类型最匹配的 MATLAB 数据类型。
NetCDF 数据类型 | MATLAB 数据类型 |
---|---|
NC_DOUBLE | double |
NC_FLOAT | single |
NC_INT64 (仅限 NetCDF-4 文件) | int64 |
NC_UINT64 (仅限 NetCDF-4 文件) | uint64 |
NC_INT | int32 |
NC_UINT (仅限 NetCDF-4 文件) | uint32 |
NC_SHORT | int16 |
NC_USHORT (仅限 NetCDF-4 文件) | uint16 |
NC_BYTE | int8 |
NC_UBYTE (仅限 NetCDF-4 文件) | uint8 |
NC_CHAR | char |
NC_STRING (仅限 NetCDF-4 文件) | string |
用户定义的 NC_VLEN 类型(仅限 NetCDF-4 文件) | cell |
版本历史记录
在 R2011a 中推出R2022a: 远程数据集的字节范围读取
只要远程服务器支持字节范围访问,您就可以使用 ncreadatt
通过 HTTP 字节范围功能对远程数据集进行只读访问。
R2022a: 读取可变长度数组数据类型 (NC_VLEN
)
您可以从 netCDF-4 文件中读取可变长度的数组数据类型 (NC_VLEN
)。
R2021b: 读取 NC_STRING
数据
您可以从 netCDF-4 文件中读取 NC_STRING
数据。
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)