Info

此问题已关闭。 请重新打开它进行编辑或回答。

How to read more than one netcdf file?

1 次查看(过去 30 天)
Jonas Damsbo
Jonas Damsbo 2018-11-21
关闭: MATLAB Answer Bot 2021-8-20
I got around 480 netcdf-files that needs to be run in the same matlab-script. The files are named in a logical format, like this:
January79, February79, Marts79, April79, May79, June79, July79, August79, September79, October79, November79, December79, January80 and so on.
To open one file I do this:
filename='December81.nc'
%Shows the contents of the file
ncdisp(filename)
%Open in read mode
ncid=netcdf.open(filename,'NOWRITE')
%Loads dimensions, variables, attributtes, unim
[ndim, nvar, natt, unlim]=netcdf.inq(ncid)
for i=0:nvar-1
[varname, xtype, dimid, natt]=netcdf.inqVar(ncid,i);
if strcmp(varname,'surf_temp')==1
varnumber=i;
end
end
for i=1:length(dimid)
[dimname, dimlength]=netcdf.inqDim(ncid,dimid(1,i))
end
for i=0:nvar-1
[varname, xtype, dimid, natt]=netcdf.inqVar(ncid,i);
if strcmp(varname,'latitude')==1
dimnumber=i
end
end
%Defines logitudes, latitudes, time og z
lon = ncread(filename,'longitude') ; nx = length(lon) ;
lat = ncread(filename,'latitude') ; ny = length(lat) ;
time = ncread(filename,'time') ; nt = length(time);
z = ncread(filename,'z') ; nz = length(z)
So my question is, how do I open more files, such as December81, January82 and February82 so I can use these data from this months in one script?

回答(0 个)

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by