Moving Average Filter not working
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Jan
il 7 Apr 2022
Modificato: Jan
il 7 Apr 2022
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 Commenti
Vedere anche
Categorie
Scopri di più su Digital Filter Design in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!