In order to truncate my signal in the frequency domain, I am applying a low pass filter with the windowing method. As a test, I chose the Hamming window. What is the cause of the oscillation at the bottom of the filtered signal? Also, it seems that the filter reduces the amplitude of the signal slightly. How can I get the same amplitude as the original signal after filtering? Is my filter functioning correctly? Since this is my first time using the filter, I may have made mistakes. I would greatly appreciate it if anyone could help.
sig = MY SIGNAL;
fs = 4000; % sampling freq. (GHz)
M = 400001; % signal length
% Filter parameters:
L = M; % filter length
fcut = 1.5; % cutoff frequency (GHz)
% Design the filter using the window method:
hsupp = (-(L-1)/2:(L-1)/2);
hideal = (2*fcut/fs)*sinc(2*fcut*hsupp/fs);
h = hamming(L)' .* hideal; % h is our filter
SIG_out = fft(sig); % signal
H = fft(h); % filter
FILT_OUT = SIG_out .* H;
filt_out = ifft(FILT_OUT);
relrmserr = norm(imag(filt_out))/norm(filt_out) % check... should be zero
freqz(h, 1, 2^16, fs)