Average values from timeseries
    16 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Kate Heisenberg
 el 19 de Feb. de 2020
  
    
    
    
    
    Respondida: Jancoba Dorley
 el 28 de Feb. de 2022
            Hiiii. I am very new to matlab. I have a timeseries of data that I would like to average for average values per hour per day per month per year ( 24*365=8760 values in output file). Basically the data is structured as follows:
Date            Time            Temperature
  1/1/2005      1:00              282.19
  1/1/2005      2:00              281.5
  1/1/2005      3:00              281.04
  1/1/2005      4:00              282.58 
....
  31/12/2014   23:00              294.75
  31/12/2014   24:00              294.57 
The data I am trying to import as individual vectors/columns or as a timetable. I would like to get a new table/matrix with 8760 new rows each averaging value of each hour of each day of each month by averaging all the 14 years of data. I have tried doing it using index or 'find' approach but it didnt quite work. Any help would be highly appreciated. Thaaanks :D
1 comentario
  Adam Danz
    
      
 el 19 de Feb. de 2020
				Then use TT2 = retime(TT,'hourly','mean') to compute the hourly mean, monthly mean, yearly, etc.
Respuesta aceptada
  Adam Danz
    
      
 el 19 de Feb. de 2020
        
      Editada: Adam Danz
    
      
 el 19 de Feb. de 2020
  
      Below is a general scetch of what you need to do.  Give it a shot and if you get stuck, share the code and let us know where you're stuck. 
- Use d = day(t,'dayofyear') to get the day-of-year number for each datatime value where t is the datetime column.
- Use h = hour(t) to get the hour of each datetime value where t is the datetime column.
- Use [G,ID] = findgroups(d,h) to group the days & hours (d and h are from the steps above)
- Use Y = splitapply(@mean,data,G) to get the mean of each group of data where 'data' is a colum in your table. G is from the previous step.
4 comentarios
Más respuestas (1)
  Jancoba Dorley
 el 28 de Feb. de 2022
        The best wway to do this is to convert the table to timetable
Example:
x = table2timetable(data); %Note that data is a table containing time xby1 datetime and xby1 double
x_daily=retime(x,'daily','mean'); %this calculates the daily mean from the datetime table
% you can do the saame to get the hourly mean.
0 comentarios
Ver también
Categorías
				Más información sobre Data Preprocessing 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!


