grouping/binning by time
Show older comments
Have the following table:
Time address
'14:49:56.421875000' 'ccccd9'
'14:49:56.421875000' 'cccccb'
'14:49:56.429687500' 'cccce0'
'14:49:56.421875000' 'ccccd8'
'14:49:56.421875000' 'ccccc5'
'14:49:56.421875000' 'cccccd'
'14:49:56.421875000' 'cccccc'
'14:49:56.421875000' 'ccccde'
'14:49:56.421875000' 'ccccd5'
'14:49:56.421875000' 'ccccd0'
'14:49:56.421875000' 'ccccdd'
'14:49:56.421875000' 'ccccd3'
'14:49:56.421875000' 'ccccd2'
'14:49:56.437500000' 'cccd03'
'14:49:56.429687500' 'ccccf3'
'14:49:56.429687500' 'ccccf6'
'14:49:56.429687500' 'cccce5'
'14:49:56.437500000' 'cccd0d'
'14:49:56.437500000' 'cccd18'
'14:49:56.437500000' 'cccd15'
'14:49:56.437500000' 'cccd11'
'14:49:56.437500000' 'cccd07'
'14:49:56.437500000' 'cccd0f'
'14:49:56.437500000' 'cccd10'
'14:49:56.437500000' 'cccd09'
'14:49:56.437500000' 'cccd0c'
'14:49:56.437500000' 'cccd0e'
'14:49:56.437500000' 'cccd12'
'14:49:56.437500000' 'cccd17'
'14:49:56.437500000' 'cccd0b'
'14:49:56.437500000' 'cccd0a'
'14:49:56.437500000' 'cccd16'
'14:49:56.437500000' 'cccd08'
'14:49:56.437500000' 'cccd13'
How can I bin and return number of 'address' in a given second?
thanks for your help
KB
Accepted Answer
More Answers (1)
If you read this in as a timetable, you can simply use retime to count the number of addresses in a given second. Starting off with dpb's code above.
data={
'14:49:56.421875000' 'ccccd9'
'14:49:56.421875000' 'cccccb'
'14:49:56.429687500' 'cccce0'
'14:49:56.421875000' 'ccccd8'
'14:49:56.421875000' 'ccccc5'
'14:49:56.421875000' 'cccccd'
'14:49:56.421875000' 'cccccc'
'14:49:56.421875000' 'ccccde'
'14:49:56.421875000' 'ccccd5'
'14:49:56.421875000' 'ccccd0'
'14:49:56.421875000' 'ccccdd'
'14:49:56.421875000' 'ccccd3'
'14:49:56.421875000' 'ccccd2'
'14:49:56.437500000' 'cccd03'
'14:49:56.429687500' 'ccccf3'
'14:49:56.429687500' 'ccccf6'
'14:49:56.429687500' 'cccce5'
'14:49:56.437500000' 'cccd0d'
'14:49:56.437500000' 'cccd18'
'14:49:56.437500000' 'cccd15'
'14:49:56.437500000' 'cccd11'
'14:49:56.437500000' 'cccd07'
'14:49:56.437500000' 'cccd0f'
'14:49:56.437500000' 'cccd10'
'14:49:56.437500000' 'cccd09'
'14:49:56.437500000' 'cccd0c'
'14:49:56.437500000' 'cccd0e'
'14:49:56.437500000' 'cccd12'
'14:49:56.437500000' 'cccd17'
'14:49:56.437500000' 'cccd0b'
'14:49:56.437500000' 'cccd0a'
'14:49:56.437500000' 'cccd16'
'14:49:56.437500000' 'cccd08'
'14:49:56.437500000' 'cccd13'};
Time=duration(data(:,1),'InputFormat','hh:mm:ss.SSSSSSSSS','Format','hh:mm:ss.SSSSSS');
Address=categorical(data(:,2));
From this point create a timetable and then call retime on it to resample it to seconds and count the number of entries in each bin
tt = timetable(Time,Address)
retime(tt,"secondly","count")
Categories
Find more on Descriptive Statistics 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!