Divide table in days and then in hours.

2 ビュー (過去 30 日間)
Erica Corradi
Erica Corradi 2018 年 6 月 16 日
コメント済み: Stephan 2018 年 6 月 26 日
Hello everyone! I'm not very practical with matlab, so I hope that someone can help me. I have a big table [351496 x 5] that it contains 6 months of monitoring. Below the first five rows of my table.
The first column is the categorical variable (they are the name of my PIR sensors) the last column (ColumnDateTime) is the date time array. I want to divide my table for days, so as to create daily subtables. then, every daily subtable I would divide it by hours, creating 4 additional tables (which correspond to the times of the day: morning, afternoon, evening, night). Then I would like to analyze if there are 2 PIR sensors that detect movements in two different rooms (the different rooms are recognized in the first column, through the names of the sensors) in a time <= to 2 seconds. Thanks in advance.

採用された回答

Stephan
Stephan 2018 年 6 月 22 日
Hi,
if you use a timetable for storing your data the function that might help you is
retime
With this function you can aggregate your data among other things. There are also examples given on the retime documentation site.
Best regards
Stephan
  6 件のコメント
Erica Corradi
Erica Corradi 2018 年 6 月 26 日
O my God!!!!! Thank you very much!!!! You solved my problem! The code works as I wanted!!Thanks thanks thanks. P.S.: sorry if I answer now, but only now I tried your code.
Stephan
Stephan 2018 年 6 月 26 日
Nice to hear... have fun

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

その他の回答 (1 件)

Razvan Carbunescu
Razvan Carbunescu 2018 年 6 月 26 日
Depending on the final goal here could use some of the functionality within groupsummary (If using R2018a) and findgroups / splitapply models to help achieve some of the final modeling.
>> groupsummary(tab,'t',hours(6),'mean','values')
ans =
12×3 table
disc_t GroupCount mean_values
____________________________________________ __________ ___________
[01-Jun-2018 00:00:00, 01-Jun-2018 06:00:00) 6 58.833
[01-Jun-2018 06:00:00, 01-Jun-2018 12:00:00) 6 61.167
[01-Jun-2018 12:00:00, 01-Jun-2018 18:00:00) 6 41.167
[01-Jun-2018 18:00:00, 02-Jun-2018 00:00:00) 6 56.5
[02-Jun-2018 00:00:00, 02-Jun-2018 06:00:00) 6 59.667
[02-Jun-2018 06:00:00, 02-Jun-2018 12:00:00) 6 42.167
[02-Jun-2018 12:00:00, 02-Jun-2018 18:00:00) 6 50.333
[02-Jun-2018 18:00:00, 03-Jun-2018 00:00:00) 6 30.667
[03-Jun-2018 00:00:00, 03-Jun-2018 06:00:00) 6 40
[03-Jun-2018 06:00:00, 03-Jun-2018 12:00:00) 6 43.833
[03-Jun-2018 12:00:00, 03-Jun-2018 18:00:00) 6 69.333
[03-Jun-2018 18:00:00, 04-Jun-2018 00:00:00] 6 62.167

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by