フィルターのクリア

Moving average with reducing sampling

3 ビュー (過去 30 日間)
Omar Aljanaideh
Omar Aljanaideh 2017 年 11 月 30 日
編集済み: Omar Aljanaideh 2017 年 11 月 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 Center および File ExchangeStatistics and Linear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by