フィルターのクリア

How to i generate monthly sequence

3 ビュー (過去 30 日間)
Ayodele Ogunkoya
Ayodele Ogunkoya 2017 年 12 月 7 日
回答済み: Akira Agata 2017 年 12 月 7 日
I will like to generate number of days for each month in a calendar year by looping from January to December. The output of each monthly data will be saved. I want run the loop for all the 365 days in a year but have output for each month. For example: daystart=[1,32,60,91,121,152,182,213,244,274,305,335] and dayend = daystart + ndays.per.month(31 28 31 30 31 30 31 31 30 31 30 31).

採用された回答

Akira Agata
Akira Agata 2017 年 12 月 7 日
You don't need to use for-loop to obtain number of days for each month. The following example generates number of days per month from Jan. to Dec. in 2017.
t = datetime(2017,1,1):calmonths(1):datetime(2018,1,1);
daysPerMonth = days(diff(t));
The result is:
>> daysPerMonth
daysPerMonth =
31 28 31 30 31 30 31 31 30 31 30 31

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by