I want to count the number of times each event (a, b, c... up until j) occurs, a(t<1 hour) b(1 hour<t<2 hours) c(2 hours<t<3 hours)... up to j( t>9 hours) based on the following sample in order to find the probability of any individual event occuring

1 回表示 (過去 30 日間)
'02:47:09'
'03:28:26'
'13:57:18'
'08:58:46'
'10:31:50'
'11:03:35'
'09:11:01'
'01:37:30'
'04:38:33'
'03:02:50'
'05:41:13'
'01:21:29'
'04:44:26'
'01:06:18'
'03:47:08'
'03:33:12'
'05:30:32'
'08:48:40'
'00:00:02'
'08:52:09'
'04:57:18'
'03:47:12'
'03:39:37'
'03:28:25'
'00:43:12'
'03:41:52'
'03:47:26'
'08:00:04'
'01:16:49'
'01:00:12'
'00:01:34'
'04:28:35'
'14:28:52'
'05:46:56'
'02:38:23'
'00:01:19'
'06:21:24'
'05:38:55'
'01:05:57'
'13:36:44'

採用された回答

David Hill
David Hill 2020 年 1 月 9 日
If your data is not in a cell array, convert to a cell array. For example:
A={'02:47:09';'03:28:26';'13:57:18';'08:58:46';'10:31:50'};
A=hours(duration(A));
a=nnz(A<1);
b=nnz(A>=1&A<2);
c=nnz(A>=2&A<3);
d=nnz(A>=3&A<4);
e=nnz(A>=4&A<5);
f=nnz(A>=5&A<6);
g=nnz(A>=6&A<7);
h=nnz(A>=7&A<8);
i=nnz(A>=8&A<9);
j=nnz(A>=9);
  2 件のコメント
Stephen23
Stephen23 2020 年 1 月 9 日
Repeated code is not very generalized, but could easily be replaced by a histogram function.
GS25
GS25 2020 年 1 月 21 日
Thank you guys!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by