필터 지우기
필터 지우기

how can i use a loop to run the specific code

조회 수: 1 (최근 30일)
Joydeb Saha
Joydeb Saha 2022년 4월 18일
댓글: Joydeb Saha 2022년 5월 10일
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);

채택된 답변

KSSV
KSSV 2022년 4월 18일
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
KSSV
KSSV 2022년 4월 18일
This is not a problem.....you can do it...
data_Wwind=netcdf(ncFile);
Joydeb Saha
Joydeb Saha 2022년 5월 10일
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) ;
data_Wwind=netcdf(ncFile);
cot=data_Wwind{'M2TMNXRAD_5_12_4_TAUHGH'}(:);
th5 = cot > 3;
B = double(th5);
Q(i)=sum(B(:) == 1);
end
I have used this code to find the total number of pixels those are above threshold 3 for all the data files in the folder. How can I find the mean value of cot for all the data files only for the pixels those are above threshold three(3)?

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

추가 답변 (1개)

Jongil Lee
Jongil Lee 2022년 4월 18일
Hi, Joydeb
I found similar question as below, please check this link.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by