Moving Average Filter: A doubt

1 次查看(过去 30 天)
Filippo Grazioli
Filippo Grazioli 2016-12-28
回答: Julian 2017-1-5
Hello,
I need to develop a moving average filter that only considers the time window PRIOR TO a certain instant. In other words, considering the value of my output signal at a certain time t0, it must be the result of the prior time window. Therefore, the averaging time window must not be centred in t0, but end in t0. The application will be implemented real-time and there is not yet a time after t0.
filtCoeff = ones(1, T)/T;
output = filter(filtCoeff, 1, input);
Do you think these two lines correctly carry out what I am trying to do? If not, how to do it?
Thanks a lot. Filippo
  1 个评论
dpb
dpb 2016-12-28
Well, the implemented as written is simply
output=mean(input);
if input is the last T values of the data feed. If, OTOH, input continues to grow over time, filter will output a vector of results of length(input) each and every time it's called--probably not what you're looking for...

请先登录,再进行评论。

回答(1 个)

Julian
Julian 2017-1-5
Yes, the 2 lines you wrote do achieve what you want. The filter function is causal and inclusively ends at t0. The much newer function movmean (since R2016a) centres on t0 by default (but allow you to specify the window extent forward and backward).

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by