How to read all variables in netcdf file
60 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ricardo Duarte
am 29 Jun. 2023
Beantwortet: Chunru
am 30 Jun. 2023
Dear all,
I have a netcdf file with 705 variables inside.
The names of the variables in the netcdf are something like this:
2020_m03_w9_spring, 2019_m11_w42_fall, 2020_m07_w12_summer, 2020_m02_w8_winter, etc, etc, etc
Note that m means month and w means weak.
So, I would like to pass all these variables to a workspace variable, using for example the function "ncread", putting all spring variables together, all fall together, all summer together and all winter together creating this way four 3d matrices.
Additionally, I would like to sort each 3d matrices according to the week.
Do you have an idea how to do this?
Thank you in advance.
0 Kommentare
Akzeptierte Antwort
Chunru
am 30 Jun. 2023
fn = "abc.nc"
ni = ncinfo(fn);
for i=1:length(ni.Variables)
vn = ni.Variables(i).Name;
x.(vn) = ncread(fn, vn); % The result is a structure
end
% Then you can organize the variables as you want
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu NetCDF finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!