How can I group column of data with the same time stamp and get the row mean of each group?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Teddy2018
el 17 de Feb. de 2019
Editada: Cris LaPierre
el 19 de Feb. de 2019

from this table to this image where
x = Height
t = time
u = zonal wind

0 comentarios
Respuesta aceptada
Cris LaPierre
el 17 de Feb. de 2019
The functions findgroup and splitapply allow you to group by similar time and take a mean of all data in each group. However, that works for column data (your raw data), and not for your summary tables (bottom images). There may be a way to create groups by hour instead of time so you don't have to combine columns.
10 comentarios
Más respuestas (2)
Peter Perkins
el 17 de Feb. de 2019
retime on a timetable is the simplest way to compute means per time bin:
>> tt = timetable(rand(10,1),'RowTimes',duration((sort(3*rand(10,1))),0,0))
tt =
10×1 timetable
Time Var1
________ _______
00:02:08 0.35166
00:09:42 0.83083
00:13:39 0.58526
00:23:22 0.54972
01:00:40 0.91719
01:24:29 0.28584
01:35:32 0.7572
01:42:23 0.75373
02:20:15 0.38045
02:48:07 0.56782
>> ttHourlyMean = retime(tt,'hourly','mean')
ttHourlyMean =
3×1 timetable
Time Var1
________ _______
00:00:00 0.57937
01:00:00 0.67849
02:00:00 0.47413
You can then unstack that if you want. It's not at all clear to me how you got to those regular heights, 3000, 2500, etc. Maybe those are height bins, and you're really doing 2-D grouping. retime won't do that, splitapply, groupsummary, or a grouped varfun is the way to go for that.
0 comentarios
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

