how can i use a loop to run the specific code
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joydeb Saha
am 18 Apr. 2022
Kommentiert: Joydeb Saha
am 10 Mai 2022
If there are number of datafiles in the current folder, how can i use a loop to run the specific code? attaching the code. the folder name is 2002. and data file names are 200201,200202,200203 etc. I need a single matrix giving the Q values for all the data files.
data_Wwind=netcdf('E:\data\2002\200201.nc'); % input address of data folder
cot=data_Wwind{'M2TMNXRAD_5_12_4_TAUHGH'}(:);
th5 = cot > 5;
B = double(th5);
Q=sum(B(:) == 1);
0 Kommentare
Akzeptierte Antwort
KSSV
am 18 Apr. 2022
ncFiles = dir('E:\data\2002\*.nc')
N = length(ncfiles) ;
Q = zeros(N,1) ;
for i = 1:N
ncFile = fullfile(ncFiles(i).folder,ncFiles(i).name) ;
cot=data_Wwind{'M2TMNXRAD_5_12_4_TAUHGH'}(:);
th5 = cot > 5;
B = double(th5);
Q(i)=sum(B(:) == 1);
end
6 Kommentare
KSSV
am 18 Apr. 2022
This is not a problem.....you can do it...
data_Wwind=netcdf(ncFile);
Weitere Antworten (1)
Jongil Lee
am 18 Apr. 2022
Hi, Joydeb
I found similar question as below, please check this link.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!