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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 4 Déc 2020
My recommendation would be to use groupsummary. Something like this (untested).
dayAvg = groupsummary(ECCC,"DateTime","dayofyear","mean")
  2 commentaires
JAT
JAT le 4 Déc 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!!!
Cris LaPierre
Cris LaPierre le 4 Déc 2020
You just made my day. You are very welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Preprocessing dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by