- 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?
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Robert
am 6 Jul. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Matched Filter and Ambiguity Function finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!