读取.nc文件时出现问题

时间:2013-07-24 13:56:47

标签: matlab

我收到了这个.nc文件。但是,当我像这样阅读文件时

ncid = netcdf.open(ncfile)

它只给我一个号码。它应该包含一些数据。我不确定它有什么问题。
有人可以提供一些信息吗?

2 个答案:

答案 0 :(得分:3)

根据documentationnetcdf.open仅返回NetCDF ID,而不是数据:

  

ncid = netcdf.open(source)打开source,可以是a的名称   NetCDF文件或OPeNDAP NetCDF数据源的URL,仅用于只读   访问。返回ncid中的NetCDF ID。

您可能想要使用ncread

答案 1 :(得分:1)

注意:

  

ncid = netcdf.open(ncfile)   其中ncid是netcdf.create或者返回的netCDF文件标识符   netcdf.open。

例如:在你的案例中

 ncid=netcdf.open(ncfile,'NC_NOWRITE'); 
 varidp=netcdf.inqVarID(ncid,'varname'); //returns varid

例如:官方

此示例打开MATLAB®,example.nc附带的示例netCDF文件,并使用多个查询函数来获取第一个变量的ID。

ncid = netcdf.open('example.nc','NC_NOWRITE');

% Get information about first variable in the file.
[varname, xtype, dimids, atts] = netcdf.inqVar(ncid,0);

% Get variable ID of the first variable, given its name
varid = netcdf.inqVarID(ncid,varname)

价:http://www.mathworks.in/help/matlab/ref/netcdf.inqvarid.html

由于

相关问题