How can i sum over seconds ?

Hej, I would like to sum up my events over seconds. So I would like to know how many counts I have in one second.
if true
% code Noisedb0061 Noisedb0062 Noisedb0063 Noisedb0064 Noisedb0065 Noisedb0066 Var7
_________________________ ___________ ___________ ___________ ___________ ___________ __________
'2017-06-18 08:00:01.324' 51 114.21 0 0 4 7.3686e+05
'2017-06-18 08:00:04.129' 67 112.63 0 0 4 7.3686e+05
'2017-06-18 08:00:04.167' 105 116.26 0 0 4 7.3686e+05
'2017-06-18 08:00:04.209' 207 118.54 0 0 4 7.3686e+05
'2017-06-18 08:00:04.251' 195 114.22 0 0 4 7.3686e+05
'2017-06-18 08:00:04.668' 43 114.54 0 0 4 7.3686e+05
'2017-06-18 08:00:06.843' 57 113.4 0 0 4 7.3686e+05
'2017-06-18 08:00:06.869' 63 116.71 0 0 4 7.3686e+05
'2017-06-18 08:00:06.895' 51 113.97 0 0 4 7.3686e+05
'2017-06-18 08:00:07.894' 73 115.6 0 0 4 7.3686e+05
end
At the end I would just need two columns on with the time and one with the counts.

3 件のコメント

jonas
jonas 2018 年 10 月 16 日
Upload the data
Sarah Gutermuth
Sarah Gutermuth 2018 年 10 月 16 日
sure okay, I just made a subsample.
ANKUR KUMAR
ANKUR KUMAR 2018 年 10 月 16 日
Whats your expected output?
"how many counts I have in one second"- please elaborate your query.

サインインしてコメントする。

回答 (2 件)

jonas
jonas 2018 年 10 月 16 日
編集済み: jonas 2018 年 10 月 16 日

1 投票

t = datetime(testclick{:,1});
ts = dateshift(t, 'start', 'second')
N = histcounts(ts,'binmethod','second')
This will also give you the zero counts. And here is a table with your counts:
tc = ts(1):seconds(1):ts(end);
T = table(tc',N')
T =
Var1 Var2
____________________ ____
18-Jun-2017 08:00:01 1
18-Jun-2017 08:00:02 0
18-Jun-2017 08:00:03 0
18-Jun-2017 08:00:04 5
18-Jun-2017 08:00:05 0

1 件のコメント

Sarah Gutermuth
Sarah Gutermuth 2018 年 10 月 16 日
Thank you for your help, it's working.

サインインしてコメントする。

Andrei Bobrov
Andrei Bobrov 2018 年 10 月 16 日
編集済み: Andrei Bobrov 2018 年 10 月 16 日

1 投票

T = testclick;
T.Noisedb0061 = datetime(T.Noisedb0061,'I','uuuu-MM-dd hh:mm:ss.SSS');
TT = table2timetable(T(:,2:end),'RowTime',T{:,1});
TTT = retime(TT,'secondly','sum');

1 件のコメント

Sarah Gutermuth
Sarah Gutermuth 2018 年 10 月 16 日
Thank you for your help, I tried it aswell. It's working.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2018 年 10 月 16 日

コメント済み:

2018 年 10 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by