Averaging and summing parts of a column based on date
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Wendy Cameron
el 24 de En. de 2019
Comentada: Wendy Cameron
el 30 de En. de 2019
Greetings Matlab community
I have some very large data sets and I am wanting to sum and average parts of a table column based on the date. I have multiple readings of e.g. temperature for a given date and want to both sum and average these for each given date and get a corresponding table with the results.
A VERY cut down version of the data is attached and I want to get a result that has three columns - the date, the average Maxium temperature and the Total max temp for each date.
Much appreciated
0 comentarios
Respuesta aceptada
per isakson
el 25 de En. de 2019
Editada: per isakson
el 25 de En. de 2019
Ten hours without an answer. Here is the result from my first experiment with timetable. See retime Resample or aggregate data in timetable, and resolve duplicate or irregular times
%%
T = readtable('Matlab question.xlsx');
%%
TT = table2timetable( T, 'rowTimes','Var1' );
%%
dm = retime( TT, 'daily','mean' );
%%
dx = retime( TT, 'daily','max' );
%%
ds = retime( TT, 'daily','sum' );
Más respuestas (1)
Andrei Bobrov
el 25 de En. de 2019
T = readtable('Matlab question.xlsx','Ra','A2:B109','ReadV',0);
out = rowfun(@tempfun,T,'G','Var1',...
'OutputV',...
{'MeanTemp' 'MaxTemp'});
function varargout = tempfun(x)
varargout = {mean(x),max(x)};
end
0 comentarios
Ver también
Categorías
Más información sobre Dates and Time 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!