How to extract all variable rows in a table for all 1-Jan's, 2-Jan's, etc over 30 years

1 visualización (últimos 30 días)
Hi, very new to Matlab and am confused after several hours of searching the answers forum
I have a 10958x6 table with measured climate variables relating to 10958 sequential days between 1979-2008. I would like to extract all the rows for the 1st-Jans (between 1979-2008) and then all the 2nd-Jans, then all the 3rd-Jans etc and calculate the average value of those 30 measurements in each column 2-6. I.e the average temperature value on the 1st Jan, over the range of 30 years, and then the average temperature on the 2nd Jan for the range of 30 years.. and so forth. So like the climate normals data you can find on Environment Canada. Note I have leap years in my data.
Picture of my data below
I know it's super simple, just not to me... I have lots of these to do so I don't want to go through and select each set of days manually again and again and again for the different datasets.
Some examples of my pathetic attempts below to select the rows...
(me trying) ind1 = ECCC(:,1) == '01-Jan-*';
(Matlab answering) Operator '==' is not supported for operands of type 'table'.
(me trying again) ind1 = ECCC.DateTime(:) == '01-Jan-*';
(Matlan wincing then answering) Unable to convert the text '01-Jan-*' to a datetime value because its format was not recognized.
Would be grateful for help with this! I need answers in layman's terms.
Thank you Matlab forum.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 4 de Dic. de 2020
My recommendation would be to use groupsummary. Something like this (untested).
dayAvg = groupsummary(ECCC,"DateTime","dayofyear","mean")
  2 comentarios
JAT
JAT el 4 de Dic. de 2020
OMG that's amazing - you answered in 5 minutes what has been taking me hours. My first question on this forum although I have used it loads. It worked perfectly. Thank you!!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Preprocessing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by