Moving Average Filter not working
조회 수: 8 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Digital Filter Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!