how to read a text file as datetime input?

16 ビュー (過去 30 日間)
Andi 2022 年 10 月 14 日
コメント済み: Walter Roberson 2022 年 10 月 14 日
Hi everyone,
I have a text file with tiem date format YYYY-MM-DD HH:MM:SS. I want to load it and convert it to datenum. Here is what i attempt so far. (data attached)
cd_ev=readmatrix('tt.txt'); % file attached
t = load('tt.txt','InputFormat','yyyy-mm-dd HH:mm:ss')
rr=readtable('tt.txt', 'Format','yyyy_mm_dd/dd hh:mm:ss');
None of the above serve fro my purpsoe.


Walter Roberson
Walter Roberson 2022 年 10 月 14 日
filename = '';
t1 = readtable(filename, 'ReadVariableNames', false);
t1.Properties.VariableNames{1} = 'Date';
t1.Date.Format = 'yyyy_MM_dd/dd HH:mm:ss'; %MM for month, HH for 24 hour hour
ans = 5×1 datetime array
2015_07_10/10 04:43:53 2015_07_18/18 02:57:26 2015_07_27/27 04:59:29 2015_07_27/27 22:15:44 2015_09_13/13 08:23:58
I am having trouble thinking of a good reason to repeat the day like you asked to.
  7 件のコメント
Walter Roberson
Walter Roberson 2022 年 10 月 14 日
addtodate is specifically designed to only accept scalar datenum. b=cand_ev(:,jj); selected a vector of datenum entries, so addtodate(b) failed.


その他の回答 (0 件)


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



Community Treasure Hunt

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

Start Hunting!

Translated by