Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I have a text file contain the date and time like this 20180405125901 (2018-April-05 12:59:01), can matlab load the file and convert it to datetime like this 05-Apr-2018 12:59:01

1 回表示 (過去 30 日間)
Thanh Cao
Thanh Cao 2018 年 4 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a text file contain the date and time like this 20180405125901 (2018-April-05 12:59:01), can matlab load the file and convert it to datetime like this 05-Apr-2018 12:59:01

回答 (2 件)

Elias Gule
Elias Gule 2018 年 4 月 5 日
try this:
str = '20180405125901';
t = datetime(str,'InputFormat','yyyyMMddhhmmss')

Peter Perkins
Peter Perkins 2018 年 4 月 6 日
If this is a CSV or similar, it's also possible to use readtable and read them in directly as datetimes. Specify the datetime format as Elias suggests. Depending on what version of MATLAB you have, detectimportoptions might also be useful.
  1 件のコメント
Thanh Cao
Thanh Cao 2018 年 4 月 6 日
Thank you Elias and Peter for your help, your solution work great for me.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by