How do I calculate the mean value for the days in a big data set?
Show older comments
Hi I have a big data set 46933x12 and the data is collected every 5 minuets and the dates looks like
2014-01-01 00:00:00
2014-01-01 00:05:00
2014-01-01 00:10:00
... I want to have mean values for each of the 11 columes. How do i do this?
6 Comments
John Chilleri
on 4 May 2017
You can acquire the mean of each column individually with,
for i = 1:12
means(i) = mean(data(:,i));
end
Hope this helps!
KL
on 4 May 2017
do you want to calculate the daily mean for these 11 variables?
Johan Wilson
on 4 May 2017
KL
on 4 May 2017
if the timestamp is always uniform like from 00:00:00 to 23:55:00, the job is much easier, is that the case for you?
Andrei Bobrov
on 4 May 2017
Edited: Andrei Bobrov
on 4 May 2017
Please attach small example of your data file.
Johan Wilson
on 4 May 2017
Accepted Answer
More Answers (2)
Andrei Bobrov
on 4 May 2017
Edited: Andrei Bobrov
on 4 May 2017
T = table2timetable(readtable('Test.Dataset.xls','ReadVariableNames',false));
out = retime(T,'daily','mean');
or for MATLAB <= R2016a
T = readtable('Test.Dataset.xls','ReadVariableNames',false);
[a,b,c] = datevec(T.Var1);
[dv,~,t] = unique([a,b,c],'rows');
[x,y] = ndgrid(t,1:size(T,2)-1);
out1 = [dv,accumarray([x(:),y(:)],reshape(T{:,2:end},[],1),[],@mean)];
1 Comment
Johan Wilson
on 4 May 2017
Edited: Johan Wilson
on 4 May 2017
Baptiste Ranguetat
on 4 May 2017
meanData = zeros(1,11);
for i=1:11
meanData(i) = mean(data(:,i));
end
Categories
Find more on Files and Folders 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!