Moving Average Filter not working

조회 수: 8 (최근 30일)
Mania Mamakon
Mania Mamakon 2022년 4월 7일
편집: Jan 2022년 4월 7일
Hey!
So i have this moving average filter that works completely when I'm inserting it directly as code but somehow will return a unfiltered signal when made into a function and calling up into code.
The function
function vectordata = filter_outlier_dwars(vectordata);
M_dwarsversnelling = 100;
for n = 1:M_dwarsversnelling-1
outlierloos_dwars(n) = vectordata(n);
end
for n = M_dwarsversnelling:length(vectordata)
TemporaryVariable = 0;
for m = 1:M_dwarsversnelling
TemporaryVariable = TemporaryVariable + vectordata(n-m+1);
end
outlierloos_dwars(n) = TemporaryVariable/M_dwarsversnelling;
end
The call up
outlierloos_dwars = filter_outlier_dwars(offsetloos_dwarsversnelling);
Thanks in advance!

답변 (1개)

Jan
Jan 2022년 4월 7일
편집: Jan 2022년 4월 7일
Replace the output variable in the first line:
function vectordata = filter_outlier_dwars(vectordata)
% ==>
function outlierloos_dwars = filter_outlier_dwars(vectordata)
With your code you apply the filter but reply the input data.
BY the way, movavg() and filter() are much faster ways.

카테고리

Help CenterFile Exchange에서 Digital Filter Design에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by