Reading multiple netcdf files and then produce a single Matlab matrix
28 views (last 30 days)
I've got various netcdf file, in total 1000. In order to make things easier, I'm working with 3 of them at the moment.
The netcdf files are located in a folder called 'OUTPUT' and are called 'output1.SOILA.01h.nc', 'output2.SOILA.01h.nc' and so on..
What I want to do is to loop over those nc files open them, read them and finally store the outputs in a single matlab matrix.
The code I used until now in order to read a single netcdf file is below, but how do i handle 1000 of them?
function data = ReadNetCDF_SA
ncid = netcdf.open(fn,'NC_NOWRITE');
[ndims nvars natts dimm] = netcdf.inq(ncid);
[varname, xtype, varDimIDs, varAtts] = netcdf.inqVar(ncid,i-1);
varid = netcdf.inqVarID(ncid,varname);
Thanks a lot,