Calculating daily average curve from weekly data

3 vues (au cours des 30 derniers jours)
Mat P
Mat P le 6 Août 2020
Commenté : Mat P le 8 Août 2020
So i have a big timetable with multiple observation from time period of one week. resolution is one hour I want to shrink it into one day time period and same 1 hour resolution. The one thing that could work is to first calculate observation averages so that the table becomes 168*1 and do a for loop to split every day of week into own columns (24*7 table) and then caculate the averages again so i finally get 24*1 table. Is there a better way to do this? timetable default "mean" function doesn't work for this because "hourly" returns only average of observations, but doesn't shrink my weekly data to daily average.
  7 commentaires
jonas
jonas le 6 Août 2020
If you provide a small set of data then I could write some example code. Regardless of method, I would strongly suggest using a timetable as basis.
Mat P
Mat P le 8 Août 2020
Thank you, I already managed to solve this problem with your suggestion and that kind of indexing what i proposed. The answer by Antonio also works well. I process this data in multiple ways, so I find it easier to just use it as an array and cell array, and store the time data as a separate vector.

Connectez-vous pour commenter.

Réponse acceptée

Antonio Ciociola
Antonio Ciociola le 6 Août 2020
If i don't get wrong, it seems that you want to perform this operation:
%% Mean along 10 columns
g1m = mean(g1,2);
%% Reshape to get a the desired size
g1m_w = reshape(g1m,[24 7]);
%% Perform the mean again
g1m = mean(g1m_w,2);
  1 commentaire
Mat P
Mat P le 8 Août 2020
This works very well also. I have no idea why 'reshape' didn't come to my mind from the very beginning.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by