07-27-2015 01:10 PM
Your calculation of gain in dB is correct: Gain(dB) = 20*log(Output Amplitude/Input Amplitude), where the log is base 10. Your expectation that the signal amplitude would be half at -3 dB is incorrect. At -3 dB, the power (not amplitude) is half of the unfiltered power. Since power is proportional to amplitude squared, the amplitude (to get half power) is 1/sqrt(2) = 0.707 at -3 dB.
07-27-2015 03:21 PM
The equation for the envelope of the frequency response can be obtained by noting that the absolute value of the numerator sin(wM/2) varies between 0 and 1. So its upper edge is 1, and you can replace sin(wM/2) with unity, to find the upper envelope of H(w). (This envelope only applies for wM/2>Pi, which is the first zero of the numerator.) Thus you get
envelope of H(w)= 1/[M*sin(w/2)]^Mp.
Note also that when w/2<<1, you can use the approximation sinx ~= x:
envelope of H(w) ~= 1/[M*w/2]^Mp
Therefore the envelope of H(w) is proportional to 1/w, 1/w^2, 1/w^3 when Mp=1,2,3. Now you see why the envelope's slope is 20, 40, 60 dB/decade when Mp=1,2,3. (Apply the equation for gain in dB, when w changes by 10X.) The approximation above is decent only when 2Pi/M < w << 1. If the number of moving average points, M, is small, for example a 5 point moving average, then there will be no frequencies which satisfy the preceding inequality for w. But you chose M=500, so there is a range of frequencies where the 20 dB/decade rolloff is apparent. If you look carefully at your plot, you will see that the frequency response starts to deviate from 20 dB/decade as frequency f (=w/2Pi) approaches 0.5 (the Nyquist frequency). This is because you are getting into the range where sin(x)~=x is not accurate.
Final comment: Since you apparently care about the frequency response properties of your lowpass filter, you might want to use a different filter. Other FIR and IIR filters have flatter passbands, sharper rolloff around the cutoff frequency, and lower sidebands.
07-31-2015 03:02 AM
Hey WCR,
thank you for your detailed answer! As I only want the DC of my signal, the moving average gives satisfying results. But I am new in the field of digital filters so I want to understand the derivation of frequency response from transfer function or cut off frequency from in dependency of points used for averaging and so on.
kind regards
Slev1n