Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to read more than one netcdf file?

1 visualizzazione (ultimi 30 giorni)
Jonas Damsbo
Jonas Damsbo il 21 Nov 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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?

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by