Averaging value in table grouping by some datetime

URGENT
I Have a table done like this
Date Value
31/12/2015 23:00:00 3
31/12/2015 23:10:00 4
31/12/2015 23:20:00 5
31/12/2015 23:30:00 6
31/12/2015 23:40:00 7
31/12/2015 23:50:00 8
so the dataset contain data taking every 10 minutes during the year 2015 i want to make the mean hourly i.e averaging all value of an hour for instance i want result like this 31/12/2015 23:00:00 where in this case 23:00:00 raprresent the average of all the value taking every 10'
Thanks in advance

1 Comment

I resolve it like this
% shift the the date toward the start of the hour 23:00:00
dataset.Date = dateshift(dataset.Date, 'end', 'start');
% taking the average groupping by Date
result = grpstats(dataset, 'Date')

Sign in to comment.

Answers (1)

Use groupsummary. If your original table is called tbl, the following would work.
meanTbl = groupsummary(tbl,"Date","hour","mean","Value")

Categories

Asked:

on 13 Mar 2020

Edited:

on 13 Mar 2020

Community Treasure Hunt

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

Start Hunting!