Reading Netcdf in a loop

조회 수: 1 (최근 30일)
TTA
TTA 2019년 9월 10일
댓글: TTA 2019년 9월 10일
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
TTA
TTA 2019년 9월 10일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2019년 9월 10일
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
TTA
TTA 2019년 9월 10일
Thank you very much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by