table2timetable adding time vector with start- and end date

조회 수: 5 (최근 30일)
Lutetium
Lutetium 2020년 10월 24일
답변: Peter Perkins 2020년 11월 18일
From the recording software I"m using, I can export my data only using minutes from a reference point but I would like to convert my data to a timetable.
I know the start date and time and end date and time and tried to create a timetable based on that information:
newTimes = [datetime('2018-07-04 21:40:42'):datetime('2018-07-17 10:02:10')];
TT = table2timetable(tblB,'rowTime',newTimes)
The data was recorded in between this time range in a approx. 5 ms interval resutling in approx. 220000000 data points. Can I interpolate all the datetime/ from start and end time somehow assuming that the data was recorded regularly?

채택된 답변

Steven Lord
Steven Lord 2020년 10월 25일
The times for a timetable can be either a datetime array or a duration array. Turn your data into a duration array and use it to build the timetable.
v = (1:5:101).';
data = v.^2;
timevector = seconds(v);
A = timetable(timevector, data)

추가 답변 (1개)

Peter Perkins
Peter Perkins 2020년 11월 18일
I'm not exactly sure what question you are asking. You can make a timetasble whose row times are durations (elapsed times), but it sounds to me like that's not what you want.
With that many rows, if you want row times that are datetimes, do something like this:
>> x = rand(220,1);
>> t0 = datetime('2018-07-04 21:40:42','Format','dd-MMM-uuuu HH:mm:ss.SSS');
>> tt = timetable(x,'StartTime',t0,'TimeStep',milliseconds(5))
tt =
220×1 timetable
Time x
________________________ _________
04-Jul-2018 21:40:42.000 0.81472
04-Jul-2018 21:40:42.005 0.90579
04-Jul-2018 21:40:42.010 0.12699
04-Jul-2018 21:40:42.015 0.91338
04-Jul-2018 21:40:42.020 0.63236
04-Jul-2018 21:40:42.025 0.09754
[snip]
This
newTimes = [datetime('2018-07-04 21:40:42'):datetime('2018-07-17 10:02:10')];
just needed a milliseconds(5) in the middle. As it was, the step was 24 hours.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by