Why bandpass filter doesn't do what it supposed to do?

8 views (last 30 days)
I created a synthetic signal in Matlab:
t = linspace(0,1,1080);
original = sin(100*2*pi*t)+1;
Then I added some noise to the signal with frequency of 5 Hz and 500 Hz.
LFnoise = sin(5*2*pi*t)+1;
HFnoise = sin(500*2*pi*t)+1;
s_noisy = original+LFnoise+HFnoise;
and the I applied the bandpass filter to remove noise and recover my original signal back as follows:
s_filtered = bandpass(s_noisy,[20 400],1080);
and what I get is not my original signal! Why is that?
I need to bandpass filter my signal with a cutoff of [20 400]. How to do that?

Answers (1)

Star Strider
Star Strider on 8 Nov 2021
I do not see what the problem is.
t = linspace(0,1,1080);
original = sin(100*2*pi*t)+1;
LFnoise = sin(5*2*pi*t)+1;
HFnoise = sin(500*2*pi*t)+1;
s_noisy = original+LFnoise+HFnoise;
s_filtered = bandpass(s_noisy,[20 400],1080);
figure
plot(t, s_noisy, '-b', t, s_filtered,'-r')
grid
xlim([0 0.1]) % 'Zoom' To Show Detail
legend('Noisy','Filtered', 'Location','best')
To me, it appears that the filter works as designed.
.
  2 Comments
azarang asadi
azarang asadi on 8 Nov 2021
The original signal is way different than the filtered one. Also my original signal is positive, how do I end up with negative for filtered signal?
Star Strider
Star Strider on 8 Nov 2021
The filter eliminated the D-C (constant) offset from the original signal, since the D-C component was beyond the low-frequency stopband of the filter. (Properly designed bandpass filters always do this.) Also, there is some heterodyning of the noise signals with the original signal, and that appears as part of the filtered signal (see the Wikipedia article section on Angle sum and difference identities). The result being that the filter cannot completely reproduce the original signal, however it comes close enough.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!