getting 'mondays' that are first day of the month without using datenum

5 ビュー (過去 30 日間)
OLUBUKOLA ogunsola
OLUBUKOLA ogunsola 2016 年 6 月 22 日
コメント済み: Star Strider 2016 年 6 月 23 日
I'm trying to get the number of mondays that are first day of the month in a year without using the inbuilt function datenum. Any hint on how to tackle this ? thanks

採用された回答

Star Strider
Star Strider 2016 年 6 月 22 日
編集済み: Star Strider 2016 年 6 月 22 日
That’s probably not possible. The weekday function implicitly uses datenum.
EDIT However, if you choose to ignore that minor problem:
Year = 2016;
Month = 1:12;
ds = regexp(sprintf('%4d/%02d/%02d\n', [repmat(Year, size(Month))' Month' ones(size(Month'))]'), '\n', 'split');
for k1 = 1:length(Month)
FirstDay(k1) = weekday(ds(k1));
end
FirstDayMonday = Month(FirstDay == 2)
FirstDayMonday =
2 8
So, in 2016, February and August begin on Mondays.
  2 件のコメント
OLUBUKOLA ogunsola
OLUBUKOLA ogunsola 2016 年 6 月 23 日
that works,thanks
Star Strider
Star Strider 2016 年 6 月 23 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by