Reading Netcdf in a loop

1 visualización (últimos 30 días)
TTA
TTA el 10 de Sept. de 2019
Comentada: TTA el 10 de Sept. de 2019
Good day guys,
Please I want this code in the attached file to read the data in the subfolders.
thank you for being there
  1 comentario
TTA
TTA el 10 de Sept. de 2019
clear all, clc,
projectdir = 'C:\Users\INPE\Desktop\NewData\COSMIC\2006\';
dinfo = dir(fullfile(projectdir,'**','*_nc')); %eg atmPrf_C004.2010.093.12.28.G28_2013.3520_nc
filenames = fullfile( projectdir, {dinfo.name} );
nfiles = length(filenames);
for K = 1 : nfiles
thisfile = filenames{K};
temperature = ncread(thisfile, 'Temp');
end
here is the code

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Sept. de 2019
When you are using ** then the files will not be in projectdir, they will be in a subfolder of it. So you need to replace
filenames = fullfile( projectdir, {dinfo.name} );
with
filenames = fullfile( {dinfo.folder}, {dinfo.name} );
The folder field did not exist for older MATLAB, but those older MATLAB did not support ** subfolder searches either.
  1 comentario
TTA
TTA el 10 de Sept. de 2019
Thank you very much

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by