Design a FIR digital differentiator. Arbitrarily choose the window function and number of samples. Plot the magnitude response.
The code is as shown below
clc;
close all;
clear all;
% define n
n = 0:18;
N = 19; % N tap filter
M = (N-1)/2;
% define window
% define the filter
h = 1./((n-M)*pi).*sin((n-M)*pi/5).*blackman(19)'.*((n>=0)-(n>=N));
h(M+1) = 2/15; % this corresponds to n=1 where the denominator is zero
% plot the filter
figure;
stem(n,h,'filled');grid on;title('h[n]');
xlabel('n');ylabel('stem height');
% plot the frequency response of the filter
figure;
freqz(h,1);grid on;
Comments
Leave a comment