NetCDF toolbox for matlab(R2008a) in windows xp
转自WZY的BLOG
【经本人亲自测试,该方法同样适合用于VISTA系统】
首先从mexnc(http://mexcdf.sourceforge.net/index.html)下载适合你的matlab版本的mexnc和netcdf_toolbox压缩包。我使用的是mexnc-2.0.31-2.R2008a.tar和netcdf_toolbox-1.0.12。
将上面两个压缩包解压,为方便管理,解压至matlab的toolbox目录下,生成两个文件夹mexnc和netcdf_toolbox;run matlab→file→set path→add folders(或者add with subfolders)→选中toolbox下的mexnc,并且将mexnc/win32下的netcdf.dll 拷贝至C:\WINDOWS\system32,重启电脑。
然后,run matlab→file→set path→add folders,将
.../toolbox/netcdf_toolbox;
.../toolbox/netcdf_toolbox/netcdf;
.../toolbox/netcdf_toolbox/netcdf/nctype;
.../toolbox/netcdf_toolbox/netcdf/ncutility
分别添加至matlab搜索路径。至此,安装完成,恭喜!
若安装成功,在matlab的command window中输入ncbrowser,将弹出NetCDF toolbox的窗口,选中你要打开的nc文件,list至command window或extract至workspace。
ncdump('filename.nc')可以用于查看nc文件中所有变量的信息。
对于批量文件,以下提供循环读取nc文件的方法。
file_stru=dir('the/path/of/the/da
file_stru.name%查看你要读取的文件的编号。file_stru(1).name和file_stru(2).name在window下分别为.和..
for n=mm:nn% 循环读取数据
filename=strcat('the/path/of/the/da
f=netcdf(filename,'nowrite');
m=n-mm+1;
var(m,:,:,:)=f{'var'}(:);%数据操作,将所有nc文件中的变量var存储为一个matlab变量var(如果nc中的var是一个三维数组,那么得到的workspace中的var就为一个四维数组)
close(f)
end
批量处理nc文件可参考(http://www.x5dj.com/Blog/00793960/00376006.shtml)