how to shift in timetable?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
i have this timetable how can i shift date time to the nearest date in timetable?
time_table = timetable({'1-Mar-2018 21:00' ; '6-Mar-2018 22:23'; '8-Mar-2018 18:20'}, ...
[1.13 ; 2.2 ; 3], {'a' , 'b' , 'c'});
1 Kommentar
Andrei Bobrov
am 31 Okt. 2018
time_table = timetable(datetime({'1-Mar-2018 21:00' ; '6-Mar-2018 22:23';...
'8-Mar-2018 18:20'},'I','dd-MMM-uuuu HH:mm'),[1.13 ; 2.2 ; 3],...
{'a' ; 'b' ; 'c'})
Antworten (1)
dpb
am 31 Okt. 2018
First need to clean up the syntax for creating the time table -- as written one gets:
>> time_table=timetable({'1-Mar-2018 21:00' ; '6-Mar-2018 22:23'; '8-Mar-2018 18:20'}, ...
[1.13 ; 2.2 ; 3], {'a' , 'b' , 'c'});
Error using tabular/countVarInputs (line 267)
All variables must have the same number of rows.
Error in timetable (line 246)
[numVars,numRows] = tabular.countVarInputs(varargin);
>>
Oh; the last is a row cell array instead of column...change commas to semi-colons and try again...
>> time_table = timetable({'1-Mar-2018 21:00' ; '6-Mar-2018 22:23'; '8-Mar-2018 18:20'},[1.13 ; 2.2 ; 3], {'a' ; 'b' ; 'c'});
Error using timetable (line 291)
Provide datetime or duration vector for row times to create timetable.
>>
Well, that doesn't work yet, either...wrap the times in call to datetime and try again...
>> time_table = timetable(datetime({'1-Mar-2018 21:00'; '6-Mar-2018 22:23'; '8-Mar-2018 18:20'}),[1.13 ; 2.2 ; 3], {'a' ; 'b' ; 'c'});
>>
OK, now we are there...on to the question asked (I actually used tt for the variable for brevity, use your chosen name as desired)--
>> tt.Time=dateshift(tt.Time,'start','day')
tt =
3×2 timetable
Time Var1 Var2
____________________ ____ ____
01-Mar-2018 00:00:00 1.13 'a'
06-Mar-2018 00:00:00 2.2 'b'
08-Mar-2018 00:00:00 3 'c'
>>
It's unfortunate lack in the documentation that dateshift isn't linked to under timetable but only with information on dates and times variable types and that retime doesn't have an option to turn off the interpolation or aggregation.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!