What type of filter is thisr?

1 view (last 30 days)
DenLi
DenLi on 26 Feb 2017
Commented: Jan on 27 Feb 2017
Hello,
I have found following piece of code:
N = length(SomeArray);
Mean_len = 4;
Offset_calc = ones(length(I_filt),1);
i=1;
while (i < N)
if (i < Mean_len/2+1)
Offset_calc(i,1) = SomeArray(i,1)-mean(SomeArray(1:Mean_len));
elseif(i < N-Mean_len/2)
Offset_calc(i,1) = SomeArray(i,1)-mean(SomeArray(i-Mean_len/2:i+Mean_len/2));
else
Offset_calc(i,1) = SomeArray(i,1)-mean(SomeArray(N-Mean_len:N));
end
i=i+1;
end
It's simple to understand. From some array a mean value is subtracted. The length of the mean value is set . It's not an Avarage Filter since you divide by the mean value in it, but here you subtract it. What does it do? Where do you use this type of filter?.... if it's even a filter.
Regards, Den

Accepted Answer

Jan
Jan on 26 Feb 2017
Edited: Jan on 26 Feb 2017
Here the moving average around each point is subtracted. Therefore it is a high pass filter: high frequencies, which change the signal inside the Mean_len window rapidly are kept, slow changes and the DC offset are removed. It is equivalent to:
B = ones(Mean_len, 1) / Mean_len;
Y = X - filter(B, 1, X);
  2 Comments
Jan
Jan on 27 Feb 2017
[Moved from asnwer to comment section:]
DenLi wrote: first of all, thank you for your answer!
Hmm now that you say it, it does make sense that high frequencies are kept, but ...still wasn't obvious to me at all. So since it's a high-pass filter, how do I figure out the cut-off frequency? It obviously depends on the length of the Moving Average ... but what is the relationship?
Thanks in advance, Den

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!