フィルターのクリア

Why isn't the year in my categorical array time properly converted in Matlab?

5 ビュー (過去 30 日間)
Javier
Javier 2019 年 10 月 30 日
回答済み: Javier 2019 年 10 月 30 日
I have the following catergorical array in Matlab
time(1:3)
ans =
3×1 categorical array
13-10-19 00:03
13-10-19 00:08
13-10-19 00:12
I want to use it as x-axis for a timeseries, in order to do so I need it as time string, so what I have done is the following
string(time(1:3))
ans =
3×1 string array
"13-10-19 00:03"
"13-10-19 00:08"
"13-10-19 00:12"
If I cavert it using either datetime or datestr the year seems to be lost or wrongly converted
datetime(string(time(1:3)))
ans =
3×1 datetime array
19-Oct-0013 00:03:00
19-Oct-0013 00:08:00
19-Oct-0013 00:12:00
datestr(string(time(1:3)))
ans =
3×20 char array
'19-Oct-0013 00:03:00'
'19-Oct-0013 00:08:00'
'19-Oct-0013 00:12:00'
Why is this? How can I convert the year properly?
Thanks in advance!

採用された回答

Javier
Javier 2019 年 10 月 30 日
I solved by using
datetime(string(time(1:3)),'InputFormat','dd-MM-yy HH:mm')

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by