how can i get the average of group of rows in time series?

2 次查看(过去 30 天)
i have time series recording one point value every 1 second, i need matlab to calculate the average of each group of 60 points to get 1 minute value along the time series(not moving average). i think i can use peravg or accumarray functions but i don't understand how to use it, so if you please could help.

回答(1 个)

W. Owen Brimijoin
I might suggest a function I have posted on the FileExchange . It's called timeseries_indexer.m and it takes a time series as an input along with timestamps, labels, and a window and outputs the exact kind of average you are looking for.
In your case, your time stamps would be
timestamps = [1:60:length(data)];
your labels would be
labels = ones(size(timestamps));
and your window would be
win = [0 59]; %to stretch from sample 1 to sample 60
Call it like so and watch the magic!
mean_data = timeseries_indexer(labels,timestamps,win,data);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by