Finding daily min and max values for time series data

23 visualizaciones (últimos 30 días)
I have a time series of data at 15 minute time intervals across a 400 day period. I am trying to extract the maximum and minimum from one column of data for each day, and then calculating the difference. I can get the maximum or minumum for each day but am unsure of how to get all of the maximim and minimum values for the entire dataset.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 6 de Sept. de 2022
Editada: Cris LaPierre el 6 de Sept. de 2022
Use groupsummary and group the data by 'day' and the method set to max and min.
Date = datetime(2016,6,4)+minutes(0:15:3000)';
X = rand(size(Date));
Y = rand(size(Date));
Z = rand(size(Date));
tbl = table(Date,X,Y,Z)
tbl = 201×4 table
Date X Y Z ____________________ ________ ________ ________ 04-Jun-2016 00:00:00 0.3386 0.043382 0.12585 04-Jun-2016 00:15:00 0.83698 0.42607 0.26318 04-Jun-2016 00:30:00 0.12522 0.4916 0.39504 04-Jun-2016 00:45:00 0.78164 0.42306 0.96615 04-Jun-2016 01:00:00 0.67576 0.22364 0.97667 04-Jun-2016 01:15:00 0.78426 0.68923 0.16458 04-Jun-2016 01:30:00 0.3168 0.3851 0.017321 04-Jun-2016 01:45:00 0.037264 0.12319 0.26101 04-Jun-2016 02:00:00 0.69026 0.71599 0.15885 04-Jun-2016 02:15:00 0.96935 0.16094 0.65121 04-Jun-2016 02:30:00 0.93266 0.62442 0.54567 04-Jun-2016 02:45:00 0.41745 0.83331 0.52272 04-Jun-2016 03:00:00 0.5479 0.6173 0.17108 04-Jun-2016 03:15:00 0.11542 0.85308 0.90392 04-Jun-2016 03:30:00 0.070657 0.38709 0.57379 04-Jun-2016 03:45:00 0.80039 0.32129 0.62989
out = groupsummary(tbl,"Date","day",["max","min"],"Z")
out = 3×4 table
day_Date GroupCount max_Z min_Z ___________ __________ _______ _________ 04-Jun-2016 96 0.97667 0.0016671 05-Jun-2016 96 0.98072 0.0024092 06-Jun-2016 9 0.81088 0.067344
out.Diff = out.max_Z-out.min_Z
out = 3×5 table
day_Date GroupCount max_Z min_Z Diff ___________ __________ _______ _________ _______ 04-Jun-2016 96 0.97667 0.0016671 0.975 05-Jun-2016 96 0.98072 0.0024092 0.97831 06-Jun-2016 9 0.81088 0.067344 0.74354

Más respuestas (0)

Categorías

Más información sobre Time Series Events en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by