Moving Average with Variable Window Size
Ältere Kommentare anzeigen
Say I have a time series with time t and data x. Both are column vectors of length n (where n can be very big).
t is sorted, but not monotonic. The step size between successive times in t is variable (and can be 0).
I'd like to calculate the simple moving average of x, but using a window size based on time, not on the number of elements.
For example, a moving average based on a 10 second window. For every t, it will take an average of the last 10s of x. But since the timestep sizes are variable, this could mean that the number of previous elements of x being averaged also varies.
I know how to do this using a loop through t, but that would be very slow considering n can be hundreds of thousands to millions of points.
Is there a clever way to do this without a loop?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB Report Generator finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!