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!