Info
この質問は閉じられています。 編集または回答するには再度開いてください。
regarding files from directory
1 回表示 (過去 30 日間)
古いコメントを表示
I have 156 different files in one folder , out of which I need to read first 13 files only and then start reading from 14 to 26 so on till 156. e.g v_1970_ch4.nc v_1970_ch4_1.nc v_1970_ch4_2.nc . .
v_1970_ch4_13.nc
v_1980_ch4_1.nc v_1980_ch4_1.nc v_1980_ch4_2.nc . .
v_1980_ch4_13.nc
I need to add data together for every 13 files, so how I can set for loop ?
[Edit: moved code from comment]
dir_list =dir('v41_CH4*');
k=0;
for i=1:length(dir_list)
vec1=zeros(720,360);
for j =1:13
k=k+1;
ncid=netcdf.open(dir_list(k).name,'NOWRITE');
latid=netcdf.inqVarID(ncid,'lat');
latitude=double(netcdf.getVar(ncid,latid));
lonid=netcdf.inqVarID(ncid,'lon');
longitude=double(netcdf.getVar(ncid,lonid));
emi_ch4id=netcdf.inqVarID(ncid,'emi_ch4');
ch4=double(netcdf.getVar(ncid,emi_ch4id));
vec1=(vec1+ch4);
end
end
1 件のコメント
Jan
2011 年 10 月 19 日
It is always a good idea to post, what you have done so far. Then we can re-use as much code as possible and do not confuse you by using different names for variables etc.
回答 (1 件)
Jan
2011 年 10 月 19 日
Does alphabetical sorting create the wanted order? Or are there problems like in:
sort({'1', '2', '9', '10', '11'})
>> '1' '10' '11' '2' '9'
1 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!