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