two for Nested Loops
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
How i can sum the third column to get the average over each 24 values of the second coloumn?
2 comentarios
Respuestas (6)
Jos (10584)
el 14 de Dic. de 2017
Editada: Jos (10584)
el 14 de Dic. de 2017
Your question is a little unclear. Do you want to sum all values of the third row when the second row equals 0, equals 1, etc, so you end up with 24 summed values? That is easy:
A = xlsread('average24');
S = accumarray(A(:,2)+1, A(:,3), [24,1], @mean)
% S(k) is the average of all values of A(:,3) when A(:,2) equals (k-1)
1 comentario
KL
el 14 de Dic. de 2017
Editada: KL
el 15 de Dic. de 2017
An example with timetable,
EDITED
%import data
data = readtable('actual data.txt');
%create a proper datetime column
data.Timestamp = datetime(cell2mat(data{:,[1 2]}),'InputFormat','yyyy.MM.ddHH:mm');
%keep only datetime and measurements
data = data(:, [end 3]);
%create timetable
TT = table2timetable(data(:,2),'rowtimes',data.Timestamp);
%calculate daily mean
TT_mean = retime(TT,'daily','mean');
0 comentarios
ahmad Saad
el 15 de Dic. de 2017
4 comentarios
KL
el 15 de Dic. de 2017
Editada: KL
el 15 de Dic. de 2017
The answer I gave you works on your text file. I tested it before posting it here!
This is the output
TT_mean =
61×1 timetable
Time Var3
__________ ______
2017-10-01 9383.2
2017-10-02 9388.9
2017-10-03 9420.8
2017-10-04 9449.3
2017-10-05 9463
2017-10-06 9456.5
2017-10-07 9406.2
2017-10-08 9364.3
2017-10-09 9386.4
2017-10-10 9440.3
...
Ver también
Categorías
Más información sobre Timetables 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!