How to average data per hour ?
11 ビュー (過去 30 日間)
古いコメントを表示
Hi
I have sensor data which is stored once a minute or at times maybe few times a minute . This is an example of the timestamps data array.
Columns 28216 through 28220
18-Apr-2022 07:14:14 18-Apr-2022 07:13:12 18-Apr-2022 07:12:09 18-Apr-2022 07:11:06 18-Apr-2022 07:10:04
Columns 28221 through 28225
18-Apr-2022 07:09:02 18-Apr-2022 07:08:01 18-Apr-2022 07:06:59 18-Apr-2022 07:05:58 18-Apr-2022 07:04:56
And this would be the sensour output
Columns 18,853 through 18,864
45.9099 48.7762 43.0352 48.7727 37.2945 37.2908 43.0245 45.8932 34.4159 28.6791 37.2786 28.6746
Columns 18,865 through 18,876
40.1419 37.2736 34.4061 57.3400 71.6705 83.1326 45.8650 45.8606 77.3876 65.9187 68.7805 54.4469
How can i preform an hourly average of my data, so that the times stamp as similar to the following:
18-Apr-2022 07:00:00 18-Apr-2022 08:00:00 18-Apr-2022 09:00:00
And the corresponding data mean is also outputted for eac hours time stamp?
0 件のコメント
採用された回答
Star Strider
2022 年 5 月 14 日
編集済み: Star Strider
2022 年 5 月 14 日
Transpose it so that the columns are rows, create it as a timetable and then use the retime function specifying 'hourly','mean'.
t = datetime({'18-Apr-2022 07:14:14' '18-Apr-2022 07:13:12' '18-Apr-2022 07:12:09' '18-Apr-2022 07:11:06' '18-Apr-2022 07:10:04' '18-Apr-2022 07:09:02' '18-Apr-2022 07:08:01' '18-Apr-2022 07:06:59' '18-Apr-2022 07:05:58' '18-Apr-2022 07:04:56'})';
s = [45.9099 48.7762 43.0352 48.7727 37.2945 37.2908 43.0245 45.8932 34.4159 28.6791].';
TT1 = timetable(t,s)
TT1r = retime(TT1,'hourly','mean')
EDIT — (14 May 2022 at 21:32)
Added example code.
.
2 件のコメント
Star Strider
2022 年 5 月 15 日
As always, my pleasure!
For different intervals, see the documentation seciton on Interpolate Timetable Data to Time Vector.
.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!