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

2 views (last 30 days)
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.

Answers (1)

W. Owen Brimijoin
W. Owen Brimijoin on 5 Feb 2015
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);

Categories

Find more on Creating and Concatenating Matrices 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!