how can I read huge asc files with textread?

1 回表示 (過去 30 日間)
Honey
Honey 2020 年 2 月 14 日
コメント済み: Honey 2020 年 2 月 14 日
Hello everyone,
I want to read a huge .asc file wich are climate daily data. The file's name are according to the date.
for example this is "ppt_19990101_asc". I have also leap years in my data. How can I read these files and arange them in 1*366 matlab cell?
thanks in advance.

回答 (1 件)

Bhaskar R
Bhaskar R 2020 年 2 月 14 日
編集済み: Bhaskar R 2020 年 2 月 14 日
Get file names and apply
ext_date = datetime(extractBetween(<your file name(here ppt_19990101_asc)>, '_', '_'), 'Format', 'yyyyMMdd');
Then read each file using textread according to your data
  2 件のコメント
Honey
Honey 2020 年 2 月 14 日
編集済み: Honey 2020 年 2 月 14 日
years = 15;
DATA = cell(years);
for yy = 1:n;
year = 1998+yy-1;
for month=1:12
if mod(year,4)==0 & (mod(year,100)~=0 & month ==2 | mod(year,400)==0) & month ==2
for Day = 1:29;
if Day<=9
P = textread(sprintf('ppt_%i020%i_asc.asc',year,year, Day),'','headerlines',6);
else
P = textread(sprintf('ppt_%i02%i_asc.asc',year,year, Day),'','headerlines',6);
end
end
elseif month==4 | month==6 | month==9 | month==11
for Day = 1:30;
if month<=9 & Day<=9
P= textread(sprintf('ppt_%i0%i0%i_asc.asc',year,year,month, Day),'','headerlines',6);
Honey
Honey 2020 年 2 月 14 日
thank you "Bhaskar R" for your answer. here is a part of my long code which I wrote it. I mean this kind of calling data to recognize leap years and date.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by