table2timetable adding time vector with start- and end date

5 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Steven Lord
Steven Lord il 25 Ott 2020
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)

Più risposte (1)

Peter Perkins
Peter Perkins il 18 Nov 2020
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.

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by