Not sure if I am doing something silly but I am not seeing lobe roll off on the frequency response of my windows and the low pass filter I made in MATLAB. Please can you help ... several hours just looking at this and my textbook -.-
It should be like this showing lobe roll off
%% Low Pass Filter
Fs=10*10^3; cutoff = 1000; %100 Hz
fc = cutoff / Fs ;
b = 800/Fs ;%Transition bandwidth of 800 Hz
M = 51 ; %Length of Filter
n = 0:1:M-1;
blackman_window = 0.42 - 0.50 * cos((2*pi*n)/(M-1)) + 0.08*cos( (4*pi*n) / (M-1));
hamming_window = 0.54 - 0.46 * cos((2*pi.*n)/(M-1));
hanning_window = 0.50 - 0.50 * cos((2*pi.*n)/(M-1));
blackman_window_ft = fftshift(fft(blackman_window)/M);
hamming_window_ft = fftshift(fft(hamming_window)/M);
hanning_window_ft = fftshift(fft(hanning_window)/M);
sinc_func = sin(2*pi*fc.*(n-((M-1)/2))) ./ (2*pi*fc.* (n-((M-1)/2)));
sinc_func((M+1)/2) = 1 ;
sinc_func_ft = fftshift(fft(sinc_func)/M);
h_lpf = sinc_func .* blackman_window;
h_lpf = h_lpf ./ sum(h_lpf); %Normalise
H_lpf = fft(h_lpf);
H_lpf = fftshift(H_lpf);
figure(1);cla;clf
subplot(3,2,1);hold on;
plot(blackman_window,'DisplayName','Blackman')
plot(hamming_window,'DisplayName','Hamming')
plot(hanning_window,'DisplayName','Hanning')
plot(sinc_func,'DisplayName','Sinc')
legend
title('Windows and Sinc Impulse Response');hold off
subplot(3,2,2);hold on;
plot(20*log10(abs(blackman_window_ft)),'DisplayName','Blackman')
plot(20*log10(abs(hamming_window_ft)),'DisplayName','Hamming')
plot(20*log10(abs(hanning_window_ft)),'DisplayName','Hanning')
plot(20*log10(abs(sinc_func_ft )),'DisplayName','Sinc')
legend
title('Window and Sinc Frequency Response (dB)');hold off;
subplot(3,2,3);hold on;
plot(h_lpf);
title('Low Pass Filter Impulse Response');hold off;
subplot(3,2,5);hold on;
plot(abs(H_lpf),'DisplayName','Magnitude');
plot(real(H_lpf),'DisplayName','Real');
plot(imag(H_lpf),'DisplayName','Imag');
legend
title('Low Pass Filter Frequency Response');hold off;
subplot(3,2,6);
plot(20*log10(abs(H_lpf)));
title('Low Pass Filter Frequency Response (dB)');