% Design a discrete-time differentiator
L = 7;
N = 2*L+1;

% Here is the impulse response
n = [-L:L].';
h = (-1).^n ./ n;
h(L+1) = 0; % Fix divide by zero

% Use a hamming window
w = hamming(N);
d = h.*w;

% Compare with and without the window
NFFT = 2^16;
f = [-NFFT/2:NFFT/2-1]/NFFT;
H = fftshift(abs(fft(h,NFFT)));
D = fftshift(abs(fft(d,NFFT)));

figure(1);
plot([-0.5 0 0.5],[pi 0 pi],'LineWidth',2);
hold on;
plot(f,[H D],'LineWidth',2);
hold off;
grid on;
legend('IIR Diff.','Rect Win Diff.','Hamming Win Diff.');
