Insert of discontinuous dates/time (yyyymmddhhmm) to the first column and filling of NAN to the second column which missing unknown field

3 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Peter Perkins
Peter Perkins il 30 Gen 2018
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.

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by