- convert your times to numeric values using datenum
- trim your times to an even multiple of step
- reshape the array of times to have step rows
- average across the rows
How to calculate average time over a given period?
21 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
My time data (Time) is set up as a cell string with format dd/mm/yy HH:MM:SS. Currently I am filtering the data by a given step (Step) and have a script set up so that the time value at the end of that period will display. The script I am using for that is;
FilteredTime=Time(Step:Step:length(Time));
How do I need to change it so that the average time (or midpoint in time) over this defined step is output rather than the end time?
0 comentarios
Respuestas (1)
Robert
el 6 de Jul. de 2016
You could
Time = cumsum(randi(25,101,1)); % dummy values for the example
step = 5;
% We will take the average of every set of 5 and will ignore the last point
% since it doesn't belong to any set of 5.
Time = Time(1:floor(end/step)*step);
% A compact way to take the average of every set
avg = mean(reshape(Time,step,[]));
% Let's take a look!
plot(1:length(Time),Time,step/2:step:length(Time),avg,'o-')
0 comentarios
Ver también
Categorías
Más información sobre Matched Filter and Ambiguity Function en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!