I'm new to signal processing but I'm trying to understand how the Butterworth filter works. To do so, I did the following: I assumed a sampling frequency of 100Hz and wanted to attentuate everything after half the Nyquist frequency. The code I used is the following
[b,a] = butter(2,0.5);
fs = 100; %Sampling frequency
t = 0:1/fs:1-1/fs;
y=0.123*sin(2*pi*20*t+0.234)+0.123*sin(2*pi*10*t); %Pair of sine curves
plot(abs(fft(y))) %This behaves as expected, with two peaks at 10 and 20
dataOut = filter(b, a, y);
figure,
plot(abs(fft(dataOut)))
I expected the second plot to be identical to the first because there are no frequencies above the Butterworth filter's cutoff anyway. However, the signal is artifically inflated (by a small amount) for all components below 25Hz and then goes to zero. See the original signal and the filtered signal below.
Is this normal behavior? If so, it is effectively adding noise in my passband, is it not? Also, this effect is a lot worse if I use a higher order Butterworth filter.