Effacer les filtres
Effacer les filtres

Moving average with reducing sampling

2 vues (au cours des 30 derniers jours)
Omar Aljanaideh
Omar Aljanaideh le 30 Nov 2017
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);

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by