Moving average with reducing sampling

1 次查看(过去 30 天)
The following is a moving average filter that uses an average of 50 samples of input signal using embedded matlab function. Beside this, How can i reduce the number of samples of output. i.e: after i get the averaged output y, how i get only one averaged value from each 100 averaged samples of y, Such that if i will reduce the sampling of the signal will be changed, if the sampling at input is 1 ms, at output will be 100 ms the output port.
function y = my_average(u) %# codegen
persistent i buf bufSum;
if isempty(buf)
buf = zeros(1,50);
bufSum = 0;
i = 1;
end
bufSum = bufSum - buf(i);
buf(i) = u;
bufSum = bufSum + u;
i = i + 1;
if i > numel(buf)
i = 1;
end
y = bufSum / numel(buf);

回答(0 个)

类别

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