Insert of discontinuous dates/time (yyyymmddhhmm) to the first column and filling of NAN to the second column which missing unknown field
1 回表示 (過去 30 日間)
古いコメントを表示
indika kathaluwa weligamage
2018 年 1 月 26 日
回答済み: Peter Perkins
2018 年 1 月 30 日
I have 1 minutes frequency monthly data files. some unknown field are missing due to not working of sensors. I want to insert new date/time (yyyymmddhhmm) filed to missing place(1st column)and fill them with NAN. Highly appreciate your effort.
0 件のコメント
採用された回答
Peter Perkins
2018 年 1 月 30 日
In recent versions of MATLAB:
>> t = readtable('Tide.txt','ReadVariableNames',false);
>> t.Properties.VariableNames = {'Time' 'X' 'Y'}
t =
11×3 table
Time X Y
________________ _____ _____
23/08/2017 00:00 4 2.044
23/08/2017 00:01 4.001 2.046
23/08/2017 00:03 4.007 2.05
23/08/2017 00:04 4.009 2.054
23/08/2017 00:07 4.017 2.061
23/08/2017 00:08 4.019 2.063
23/08/2017 00:09 4.022 2.065
23/08/2017 00:10 4.023 2.067
23/08/2017 00:11 4.026 2.069
23/08/2017 00:13 4.028 2.072
23/08/2017 00:14 4.03 2.074
>> tt = table2timetable(t)
tt =
11×2 timetable
Time X Y
________________ _____ _____
23/08/2017 00:00 4 2.044
23/08/2017 00:01 4.001 2.046
23/08/2017 00:03 4.007 2.05
23/08/2017 00:04 4.009 2.054
23/08/2017 00:07 4.017 2.061
23/08/2017 00:08 4.019 2.063
23/08/2017 00:09 4.022 2.065
23/08/2017 00:10 4.023 2.067
23/08/2017 00:11 4.026 2.069
23/08/2017 00:13 4.028 2.072
23/08/2017 00:14 4.03 2.074
>> tt = retime(tt,'minutely')
tt =
15×2 timetable
Time X Y
________________ _____ _____
23/08/2017 00:00 4 2.044
23/08/2017 00:01 4.001 2.046
23/08/2017 00:02 NaN NaN
23/08/2017 00:03 4.007 2.05
23/08/2017 00:04 4.009 2.054
23/08/2017 00:05 NaN NaN
23/08/2017 00:06 NaN NaN
23/08/2017 00:07 4.017 2.061
23/08/2017 00:08 4.019 2.063
23/08/2017 00:09 4.022 2.065
23/08/2017 00:10 4.023 2.067
23/08/2017 00:11 4.026 2.069
23/08/2017 00:12 NaN NaN
23/08/2017 00:13 4.028 2.072
23/08/2017 00:14 4.03 2.074
Or perhaps even
>> tt = retime(tt,'minutely','spline')
tt =
15×2 timetable
Time X Y
________________ ______ ______
23/08/2017 00:00 4 2.044
23/08/2017 00:01 4.001 2.046
23/08/2017 00:02 4.004 2.0475
23/08/2017 00:03 4.007 2.05
23/08/2017 00:04 4.009 2.054
23/08/2017 00:05 4.0116 2.0571
23/08/2017 00:06 4.0145 2.0592
23/08/2017 00:07 4.017 2.061
23/08/2017 00:08 4.019 2.063
23/08/2017 00:09 4.022 2.065
23/08/2017 00:10 4.023 2.067
23/08/2017 00:11 4.026 2.069
23/08/2017 00:12 4.0275 2.0705
23/08/2017 00:13 4.028 2.072
23/08/2017 00:14 4.03 2.074
Prior to R2016b, you'd have to do without timetables, and you may have to convert the first column of that file from text to datetime after reading. But you can recreate the call to retime using interp1.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Timetables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!