split timetables into multiple hourly timetables and save as separate .mat files
Show older comments
I have some timeseries sensor data that start at a random time and end at a random time (a sample shown below):
08/05/2019,16:24:37.988776000 0.464062500000000 4.68968700000000
08/05/2019,16:24:37.989776000 0.580312500000000 4.75656200000000
08/05/2019,17:24:37.990776000 0.679687500000000 3.00000000000000
08/05/2019,16:24:37.991776000 0.472500000000000 4.95500000000000
08/05/2019,18:24:37.992776000 0.670312500000000 4.75718800000000
I am trying to split the timetable into separate timetables for each hour of data. I've used the discretise function and created a bin column based on the hours each row of data corresponds to using the script:
test = load([dir_file,test_name,'.mat']);
ttab = test.test_timetable;
binned = discretize(ttab.Var1,'Hour');
tab_binned = table(ttab.Var1,ttab.X,binned);
tab_binned.Properties.VariableNames = {'var2','var1','binned'};
ttab_c_binned = [ttab,tab_binned(:,{'binned'})];
I could use for loops and split the time table and save separate time tables per hour but I wondered if there was a neater way of doing this?
Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Timetables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!