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