Time Series with unique column values

10 views (last 30 days)
Duy Doan
Duy Doan on 15 Aug 2018
Edited: jonas on 15 Aug 2018
I have a csv data file that I've attached. I am looking to split the data into 5 minute intervals and find the mean of each unique column value under 'label' (i.e. 'cpu', 'memory', 'disk') within that interval.
I understand that the discretize function of matlab can bin my datetime data with respect to 'time', however the problem I am having sorting the unique column vectors of 'label' for the bins in order to categorize them individually with respect to their 'label'.
Essentially, I am looking for an output that will resemble something similar to: 'cpu_mean: xxx memory_mean: xxx disk_mean: xxx'
for their respective intervals. But i am not sure how to address the unique column values of 'label'.

Answers (1)

jonas
jonas on 15 Aug 2018
Edited: jonas on 15 Aug 2018
Something like this
data=readtable('sample09.csv')
[G nms]=findgroups(data(:,1));
t = datetime(data{:,2},'InputFormat','yyyy-MM-dd''T''HH:mm:ss.SSSXXX','TimeZone','UTC')
t1=t(G==1);
TT=timetable(t1,data{G==1,3},data{G==2,3},data{G==3,3});
TT=sortrows(TT);
newtime=t1(end):minutes(5):t1(1);
TT_mean=retime(TT,newtime,'mean')
TT_mean.Properties.VariableNames=nms{:,1}'
t1 cpu disk memory
____________________ _____ _____ ______
01-Aug-2018 18:26:00 0.304 0.716 0.294
01-Aug-2018 18:31:00 0.714 0.686 0.252
01-Aug-2018 18:36:00 0.408 0.668 0.554
01-Aug-2018 18:41:00 0.45 0.642 0.516
01-Aug-2018 18:46:00 0.498 0.626 0.366
01-Aug-2018 18:51:00 0.568 0.592 0.286
01-Aug-2018 18:56:00 0.628 0.566 0.388
01-Aug-2018 19:01:00 0.382 0.552 0.322
01-Aug-2018 19:06:00 0.41 0.524 0.568
...
This works if all three measurements are taken at the same times, i.e. for each time you have three values (cpu/disk/memory). This seems to be the case when I checked the data.

Community Treasure Hunt

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

Start Hunting!