table2timetable adding time vector with start- and end date

3 Ansichten (letzte 30 Tage)
Lutetium
Lutetium am 24 Okt. 2020
Beantwortet: Peter Perkins am 18 Nov. 2020
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?

Akzeptierte Antwort

Steven Lord
Steven Lord am 25 Okt. 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)

Weitere Antworten (1)

Peter Perkins
Peter Perkins am 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.

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by