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

2 Ansichten (letzte 30 Tage)
zeinab
zeinab am 5 Feb. 2015
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.

Antworten (1)

W. Owen Brimijoin
W. Owen Brimijoin am 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);

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by