How to separate each month of this file?

1 回表示 (過去 30 日間)
Mohamed Nedal
Mohamed Nedal 2020 年 1 月 9 日
コメント済み: Mohamed Nedal 2020 年 1 月 9 日
Hello everyone,
Kindly find the attached files (1 data file + 1 description file).
The data file represents data for the whole year of 2018.
Each row represents a data record per hour so that it starts from hour=0 (the 3rd column) to hour=23 and starts again from hour=0 for the next day, and so on.
The days are represented as the Day of Year (DOY) in the 2nd column.
I need to loop over the rows and save each month separately in a text file (i.e. m1, m2, ..., m12).
The issue is that some months have 30 days, some have 31 days, and April sometimes has 28 days or 29 days.
Could you tell me how to separate the whole year into months?
I really appreciate your help.

採用された回答

David Hill
David Hill 2020 年 1 月 9 日
M=cell(1,12);
cy=[0,31,59,90,120,151,181,212,243,273,304,334,365]*24;
for k=2:13
M{k-1}=yourMatrix(cy(k-1)+1:c(k),:);
end
  4 件のコメント
Mohamed Nedal
Mohamed Nedal 2020 年 1 月 9 日
Nice. Thanks a lot
Mohamed Nedal
Mohamed Nedal 2020 年 1 月 9 日
Is cy constant for any year? Can it be general or it will need to be changed according to Febreuary whether it's 28 or 29 days?

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by