I am trying to filter a sinusoid ($f_{sample}=50 Hz$) ,, i need to remove all frequencies above 10 Hz with accepted transition region 2 Hz (stop band freq=12 Hz)
the question is why after filtering this signal is the 20 Hz still appearing in the FFT? is there something wrong ? I know results should be the same in frequency and time domain filtering but the first in multiplication and the 2nd in convolution.
here is the code :
t=[0:1/50:1];
y=cos(2*pi*20*t)+0.5*sin(2*pi*5*t);
fsamp=50;
frange=[10 12];
mag=[1 0];
devs=[0.02 0.02];
frange=[10 12];
[n,fo,ao,w] = firpmord(frange,mag,devs,fsamp);
n = n + rem(n,2);
b=firpm(n,fo,ao,w,'hilbert');
%%% filter in time domain
final1=filter(b,1,y);
finalfft=abs(fft(final1));
t=[0:1/50:(length(finalfft)-1)/50];
f=[(t/t(end))*50];
figure(1);plot(f,abs(fft(y)));
figure(2);plot(f,finalfft);
%%% filter in freq domain
paddedfft=fft(y);
bfft=fft(b,length(y));
finalfft=paddedfft.*bfft;
final1=ifft(finalfft);
t=[0:1/50:(length(finalfft)-1)/50];
f=[(t/t(end))*50];
t=[0:1/50:(length(final1)-1)/50];
figure(3);plot(f,abs(fft(final1)));