creating year, month, day in month, hours in a day and minutes in that hour MATRIX for any year (e.g 2016)

2 ビュー (過去 30 日間)
I want to create a matrix of 525600x5 in which i want first column year, second column month in year, third column day in a month, fourth column hour in a day, and fifth minute in an hour..
viz. 2016 1 0 0 0 1
2016 1 0 0 0 2
.
.
.
.
.2016 12 31 23 60
  2 件のコメント
Stephen23
Stephen23 2021 年 3 月 7 日
2016 was a leap year, so it actually had:
366 * 24 * 60 % minutes
ans = 527040
not 525600 as you wrote.
Mohammed Yousuf
Mohammed Yousuf 2021 年 3 月 7 日
Thanks for your answer sir..
Actually i have 365 days because 31 Dec data is not available. But you are right sir. Thanks again

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

採用された回答

Stephen23
Stephen23 2021 年 3 月 7 日
T1 = datetime(2016,1,1,0,0,0);
T2 = datetime(2017,1,1,0,0,0)-minutes(0.5);
V = (T1:minutes(1):T2).';
M = [V.Year,V.Month,V.Day,V.Hour,V.Minute]
M = 527040×5
2016 1 1 0 0 2016 1 1 0 1 2016 1 1 0 2 2016 1 1 0 3 2016 1 1 0 4 2016 1 1 0 5 2016 1 1 0 6 2016 1 1 0 7 2016 1 1 0 8 2016 1 1 0 9

その他の回答 (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