Date and Time from Text with Literal Characters, Part 3

2 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2020 年 12 月 6 日
コメント済み: alpedhuez 2020 年 12 月 7 日
The data is like
Date Visitors
'Jan 1 2020' 100
'Jan 2 2020' 50
I now want to create a new variable 'date' and set the value of the second row to be 1/1/2020, and then increment one by one. How can one let Matlab do this?

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 12 月 7 日
編集済み: Cris LaPierre 2020 年 12 月 7 日
date1 = datetime('Jan 1 2020','InputFormat', 'MMM dd uuuu','Format','M/d/yy');
date2 = datetime('Jan 5 2020','InputFormat', 'MMM dd uuuu','Format','M/d/yy');
date = date1:days(1):date2
date = 1×5 datetime array
1/1/20 1/2/20 1/3/20 1/4/20 1/5/20
Or if you know the number of rows but not the end date:
date = date1 + days(0:4)
date = 1×5 datetime array
1/1/20 1/2/20 1/3/20 1/4/20 1/5/20
  2 件のコメント
Cris LaPierre
Cris LaPierre 2020 年 12 月 7 日
I suggest this documentation page as well.
alpedhuez
alpedhuez 2020 年 12 月 7 日
Let me work on it.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by