Averaging and summing parts of a column based on date
Show older comments
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
Accepted Answer
More Answers (1)
Andrei Bobrov
on 25 Jan 2019
0 votes
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
Categories
Find more on Timetables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!