Create a numeric variable with date+hour

Hi. I have a problem when I want to create a numeric variable which contains date + hour. This is my data:
So... I want to obtain a number with the sumatory by rows (both columns are strings). Can you help me?
Thanks!
MATLAB VERSION: R19b

2 件のコメント

David E.S.
David E.S. 2021 年 2 月 11 日
I don't know how to merge both columns in order to create other which have date + space + hour.

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

 採用された回答

Steven Lord
Steven Lord 2021 年 2 月 11 日

0 投票

How are you planning to use this "numeric variable with date+hour"? It's quite likely that you can achieve your goal with a datetime array.
dateAndTime = ["19/11/19", "05:16:41"; "19/11/19", "05:19:03"; "19/11/19", "05:21:26"]
dateAndTime = 3×2 string array
"19/11/19" "05:16:41" "19/11/19" "05:19:03" "19/11/19" "05:21:26"
dATWithSpace = join(dateAndTime, " ")
dATWithSpace = 3×1 string array
"19/11/19 05:16:41" "19/11/19 05:19:03" "19/11/19 05:21:26"
dt = datetime(dATWithSpace, 'InputFormat', 'dd/MM/yy hh:mm:ss')
dt = 3×1 datetime array
19-Nov-2019 05:16:41 19-Nov-2019 05:19:03 19-Nov-2019 05:21:26
For example, you can plot with it.
plot(dt, [1 4 9], 'o-')

1 件のコメント

David E.S.
David E.S. 2021 年 2 月 11 日
Excellent explanation, very useful. Thanks!!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

タグ

質問済み:

2021 年 2 月 11 日

コメント済み:

2021 年 2 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by