DSP_ IPCC
DSP_ IPCC
Harish M S, AIT
Expt No 1: Program to generate the following discrete time signals. a) Unit sample sequence,
b)Unit step sequence, c) Exponential sequence, d)Sinusoidal sequence, e) Random sequence
Theory: Discrete time signals denoted as 𝒙(𝒏), discrete time signal values are defined at discrete
instant of time only. In discrete signals, time is discritized but amplitude is continuous. The
discrete time signals are derived from continuous time signal by uniform sampling,
mathematically
𝑥(𝑛) = 𝑥(𝑡)|𝑡=𝑛𝑇𝑠 , 𝑛 = 0, ±1, ±2, … …
Where, 𝑥(𝑡) is a continuous time signal, in continuous signal, signal value is defined for all the
values of time t. And 𝑇𝑠 is the sampling interval or sampling period in seconds, it also a spacing
between the successive samples or sequence. Let us generate different types of discrete time
signals using MatLab codes.
a) Unit sample sequence: The unit sample sequence or unit impulse is denoted as 𝛿 (𝑛) and is
defined as
1, 𝑓𝑜𝑟 𝑛 = 0
𝛿 (𝑛 ) = {
0, 𝑓𝑜𝑟 𝑛 ≠ 0
MatLab program for unit impulse signal
clc;
clear all;
close all;
n=-2:1:2;
y=[zeros(1,2),ones(1,1),zeros(1,2)];
stem(n,y)
title('Unit impulse signal')
xlabel('Independent variable n')
ylabel('Amplitude')
b) Unit step sequence: The unit step signal is denoted as 𝑢(𝑛) and is defined as
1, 𝑓𝑜𝑟 𝑛 ≥ 0
𝑢 (𝑛 ) = {
0, 𝑓𝑜𝑟 𝑛 < 0
1
Prepared by Dr. Harish M S, AIT
2
Prepared by Dr. Harish M S, AIT
stem(n,y)
title('Real part of complex exponential signal');
xlabel('Independent variable n')
ylabel('Amplitude')
3
Prepared by Dr. Harish M S, AIT
4
Prepared by Dr. Harish M S, AIT
Expt No 2: Program to perform the following operations on signals. a) Signal addition, b) Signal
multiplication, c) Scaling, d) Shifting, e) Folding
Theory: If the signal is applied to the system, the system performs the prescribed operation on
the input signal and produces the desired output signal. The operations on signals are of two
types.
1. Operation performed on dependent variables
2. Operation performed on the independent variables
Operation performed on the dependent variable are
i. Signal addition
ii. Signal multiplication
iii. Signal scaling
Operation performed on the independent variable are
i. Signal shifting
ii. Signal folding
Signal addition: Let 𝑥1 (𝑛) and 𝑥2 (𝑛) are pair of discrete time signal. Then the signal 𝑦(𝑛) is
obtained by the addition of 𝑥1 (𝑛) and𝑥2 (𝑛) is defined by 𝑦(𝑛) = 𝑥1 (𝑛) + 𝑥2 (𝑛)
Signal multiplication: Let 𝑥1 ( 𝑛) and 𝑥2 (𝑛) are pair of discrete time signal. Then the signal
𝑦(𝑛) is obtained by the multiplication of 𝑥1 (𝑛) and𝑥2 (𝑛) is defined by
𝑦(𝑛) = 𝑥1 (𝑛)𝑥2 (𝑛)
Signal scaling: Let 𝑥(𝑛) denotes a discrete time signal. Then the signal 𝑦(𝑛) resulting from
amplitude scaling applied to 𝑥(𝑛) is defined by 𝑦(𝑛) = 𝑎𝑥(𝑛) .Where 𝑎 is scaling factor, if 𝑎 <
1 signal is attenuated, if 𝑎 > 1 signal is amplified.
Signal shifting: Let 𝑥(𝑛) denotes the discrete time signal. The time shifted version of 𝑥(𝑛)
is 𝑦(𝑛) = 𝑥(𝑛 − 𝑘).Where 𝑘 is the time shift operator, if 𝑘 > 0 the signal y (n) is obtained by
shifting 𝑥(𝑛) towards right by k samples. If 𝑘 < 0 the signal 𝑦(𝑛) is obtained by shifting 𝑥(𝑛)
to the left by k samples, and shift operator k must be an integer.
Signal folding: Let 𝑥(𝑛) denotes the continuous time signal, the reflection or folded version of
𝑥(𝑛) is 𝑦(𝑛) is obtained by replacing t by −𝑛 . Therefore reflection of 𝑥(𝑛) is
𝑦(𝑛) = 𝑥(−𝑛)
5
Prepared by Dr. Harish M S, AIT
clc;
clear all;
close all;
n1=input('Enter the range of first signal');
x1=input('Enter the samples of first signal');
n2=input('Enter the range of second signal');
x2=input('Enter the samples of second signal');
if n1(1)<n2(1)
x2=[zeros(1,abs((abs(n1(1)))-(abs(n2(1))))),x2];
end
if n1(1)>n2(1)
x1=[zeros(1,abs((abs(n1(1)))-(abs(n2(1))))),x1];
end
if n1(2)<n2(2)
x1=[x1,zeros(1,abs((abs(n1(2)))-(abs(n2(2)))))];
end
if n1(2)>n2(2)
x2=[x2,zeros(1,abs((abs(n1(2)))-(abs(n2(2)))))];
end
N1=min(n1(1),n2(1));
N2=max(n1(2),n2(2));
n=N1:N2;
subplot(3,1,1)
stem(n,x1)
subplot(3,1,2)
stem(n,x2)
y=x1+x2;
subplot(3,1,3)
stem(n,y)
6
Prepared by Dr. Harish M S, AIT
end
if n1(2)>n2(2)
x2=[x2,zeros(1,abs((abs(n1(2)))-(abs(n2(2)))))];
end
N1=min(n1(1),n2(1));
N2=max(n1(2),n2(2));
n=N1:N2;
subplot(3,1,1)
stem(n,x1)
subplot(3,1,2)
stem(n,x2)
y=x1.*x2;
subplot(3,1,3)
stem(n,y)
7
Prepared by Dr. Harish M S, AIT
shifted=n1+shift;
else
shifted=n1+shift;
end
subplot(2,1,2)
stem(shifted,x)
title('Shifted signal')
xlabel('Time index n')
ylabel('Amplitude of the signal')
8
Prepared by Dr. Harish M S, AIT
Expt No 3: Program to perform convolution of two given sequences (without using built-in
function) and display the signals.
Theory: Convolution is a mathematical operation used to express the relation between input and
output of an LTI system. It relates input, output and impulse response of an LTI system. The
impulse response is the response due to impulse input denoted input ℎ(𝑛). The important
significance of convolution is, if we know the impulse response h (n) of the system we can find
the output y (n) for any arbitrary input signal x (n). For discrete time signal x (n) and h (n), the
linear convolution is defined as
𝑦(𝑛) = 𝑥(𝑛) ∗ ℎ(𝑛) = ∑𝑘𝑘=−∞ 𝑥(𝑘)ℎ(𝑛 − 𝑘) = ∑𝑘𝑘=−∞ ℎ(𝑛 − 𝑘)𝑥(𝑘) −∞ ≤ 𝑛 ≤ ∞
MatLab program for convolution two signals without using built-in function
clc;
clear all;
close all;
x1=input('Enter the samples of the first signal');
x2=input('Enter the samples of the second signal');
N1=length(x1);
N2=length(x2);
N=N1+N2-1;
n=0:N-1;
x1=[x1,zeros(1,N-N1)];
x2=[x2,zeros(1,N-N2)];
subplot(3,1,1);
stem(n, x1);
title('First signal')
xlabel('Time index n')
ylabel('Amplitude')
subplot(3,1,2)
stem(n, x2);
title('Secong signal')
xlabel('Time index n')
ylabel('Amplitude')
for n1=1:N
y(n1)=0;
for i=1:N
j=n1-i+1;
if (j<=0)
j=N+j;
end
y(n1)=y(n1)+x1(i)*x2(j);
end
end
9
Prepared by Dr. Harish M S, AIT
disp('y')
disp(y);
l=0:1:N-1;
subplot(3,1,3)
stem(l,y)
title('Convolued signal')
xlabel('Time index n')
ylabel('Amplitude')
10
Prepared by Dr. Harish M S, AIT
Expt No 4: Consider a causal system 𝑦(𝑛) = 0.9𝑦(𝑛 − 1) + 𝑥(𝑛). a) Determine 𝐻(𝑧) and
sketch its pole zero plot. b) Plot |𝐻(𝑒 𝑗𝜔 )| and ∠ 𝐻(𝑒 𝑗𝜔 ). c) Determine the impulse response
ℎ(𝑛).
Theory:
a. Determine 𝑯(𝒛) and sketch its pole zero plot.
Any digital linear time invariant (LTI) system can be represented by difference equation. The
difference equation relates the input and output of the system. The general form of linear
constant coefficient difference equation is
𝑁 𝑀
∑ 𝑎𝑘 𝑦(𝑛 − 𝑘) = ∑ 𝑏𝑘 𝑥(𝑛 − 𝑘)
𝑘=0 𝑘=0
Where 𝑎𝑘 and 𝑏𝑘 are contents, 𝑥(𝑛) is an input and 𝑦(𝑛) is the output of the system and N is the
order of the system. The given difference equation 𝑦(𝑛) = 0.9𝑦(𝑛 − 1) + 𝑥(𝑛) is a first order
system.
The z-transform is a powerful mathematical tool for the analysis of discrete time LTI systems
and signals. The z-transform of a discrete time signal 𝑥(𝑛) is defined as
∞
11
Prepared by Dr. Harish M S, AIT
In this part we have to plot magnitude plot |𝐻(𝑒 𝑗𝜔 )| and phase angle plot∠ 𝐻(𝑒 𝑗𝜔 ) of Discrete
Time Fourier Transform (DTFT) of ℎ(𝑛). Let ℎ(𝑛)is impulse response of the system and the
given difference equation is 𝑦(𝑛) = 0.9𝑦(𝑛 − 1) + 𝑥(𝑛) and its corresponding transfer
1
function of the system is 𝐻 (𝑧) = 1−0.9𝑧 −1
1 1 1
𝐻 (𝜔 ) = −𝑗𝜔
= =
1 − 0.9𝑒 1 − 0.9(𝑐𝑜𝑠𝜔 − 𝑗𝑠𝑖𝑛𝜔) 1 − 0.9𝑐𝑜𝑠𝜔 − 𝑗0.9𝑠𝑖𝑛𝜔
1
Magnitude of 𝐻 (𝜔)is |𝐻(𝜔)| = and phase angle of 𝐻(𝜔)is∠ 𝐻(𝑒 𝑗𝜔 ) =
√(1−0.9𝑐𝑜𝑠𝜔)2 +(0.9𝑠𝑖𝑛𝜔)2
0.9𝑠𝑖𝑛𝜔
−𝑡𝑎𝑛−1 (1−0.9𝑐𝑜𝑠𝜔 ).
12
Prepared by Dr. Harish M S, AIT
ylabel('Amplitude')
subplot(2,1,2)
plot(omega,angle(H))
title('Phase plot')
xlabel('Omega in radian')
ylabel('Amplitude')
Apply the inverse z-transform, we get impulse response ℎ(𝑛) = 0.9𝑚 𝑢(𝑛)
MatLab program for impulse response 𝒉(𝒏)
clc;
close all;
N=input('Enter the length of the impulse respone');
num=input('Enter the coefficient of the numerator');
den=input('Enter the coefficient of the denominator');
y=impz(num,den,N);
n=0:N-1;
stem(n,y)
title('Impulse response')
xlabel('Time index n')
ylabel('Amplitude')
13
Prepared by Dr. Harish M S, AIT
Expt No 5: Computation of N point DFT of a given sequence (without using built-in function)
and to plot the magnitude and phase spectrum.
Introduction to DFT: In sampling theorem we have studied time domain sampling, it involves
conversion of continuous signal in to discrete time signal.
The Discrete Fourier Transform (DFT) is a frequency domain sampling. We know that for the
frequency domain analysis of digital signal, the digital signal 𝑥(𝑛) is converted in to frequency
domain. The frequency domain representation of signal 𝑥(𝑛) is Discrete Time Fourier transform
(DTFT) denoted as 𝑋(𝜔).The DTFT 𝑋(𝜔) is a continuous periodic signal with period 2𝜋
radians, which is function of function of 𝜔 radians. To process the 𝑋(𝜔) in the DSP processor,
we need to take N samples in one period of 𝑋(𝜔). The sampled values of 𝑋(𝜔) are known as
DFT coefficients denoted as 𝑋(𝑘). The 𝑋(𝑘) is a complex quantity, the basic equation to find
the N-point DFT of a sequence 𝑥(𝑛) is given by
𝑋(𝑘) = ∑𝑁−1 𝑛𝑘
𝑛=0 𝑥 (𝑛 )𝑊𝑁 0≤ 𝑘 ≤ 𝑁−1
−𝑗2𝜋𝑛𝑘
𝑊𝑁𝑛𝑘 = 𝑒 𝑁 is known as twiddle factor
Suppose if the digital signal 𝑥(𝑛) consists of L samples, and 𝑋(𝑘) be the N-point DFT of𝑥(𝑛).
If 𝑁 ≥ 𝐿, there is no under sampling and signal x (n) is recovered from the 𝑋(𝑘) by taking IDFT.
If 𝑁 < 𝐿, there is an under sampling and x (n) cannot be reconstructed by taking IDFT.
MatLab program for N-point DFT
clc;
close all;
x=input('Enter the sequence x[n]=');
N=input('Enter the length of DFT=');
%Zero padding
m=length(x);
if N>m
x=[x,zeros(1,N-m)];
end
%Create matrix Q
n=0:N-1;
k=0:N-1;
Q=n'*k;
%twiddle factor wn
wn=exp(-i*20*pi/N);
%create Wk0
Wk=wn.^Q;
%Compute DFT
xk=Wk*x'
14
Prepared by Dr. Harish M S, AIT
15
Prepared by Dr. Harish M S, AIT
Expt No 6: Using the DFT and IDFT, compute the following for any two given sequences a)
Circular convolution b) Linear convolution.
Theory: Linear convolution: Linear Convolution is a mathematical operation used to express
the relation between input and output of an LTI system. It relates input, output and impulse
response of an LTI system. The important significance of convolution is, if we know the impulse
response h (n) of the system we can find the output y (n) for any arbitrary input signal x (n). The
linear convolution of two discrete- time signals x (n) and h (n is defined as
𝑦(𝑛) = 𝑥(𝑛) ∗ ℎ(𝑛) = ∑𝑘𝑘=−∞ 𝑥 (𝑘)ℎ(𝑛 − 𝑘) −∞ ≤ 𝑛 ≤ ∞
Linear convolution can be performed using DFT and IDFT method also. Let 𝑥(𝑛 ) be a discrete
time signal of length 𝑁1 . Let ℎ(𝑛 ) be a discrete time signal of length 𝑁2 . If we convolve these
two signals we get 𝑦(𝑛)i.e. 𝑦(𝑛) = 𝑥(𝑛) ∗ ℎ(𝑛). The length of 𝑦(𝑛)is 𝑁 = 𝑁1 + 𝑁2 − 1. Using
N-point DFT and IDFT we can perform the linear convolution.
Circular convolution: Circular convolution is also known as periodic convolution. In circular
convolution samples are shifted circularly, in linear convolution the samples are shifted linearly
left and right. Let 𝑥1 (𝑛) and 𝑥2 (𝑛) are finite duration sequences both of length N with DFT’s
𝑋1 (𝑘) and 𝑋1 (𝑘). Circular convolution of two given sequences 𝑥(𝑛) and ℎ(𝑛) is given by the
equation
𝑦(𝑛) = 𝐼𝐷𝐹𝑇{𝑌 (𝑘)} Where 𝑌(𝑘 ) = 𝑋1 (𝑘)𝑋2 (𝑘)
𝑦(𝑛) = 𝑥(𝑛) ⊛ ℎ(𝑛) = ∑𝑁−1
𝑚=0 𝑥 (𝑚 )ℎ((𝑛 − 𝑚))𝑁 , 0 ≤ 𝑛 ≤ 𝑁 − 1
16
Prepared by Dr. Harish M S, AIT
17
Prepared by Dr. Harish M S, AIT
Expt No 7: Verification of Linearity property, circular time shift property & circular frequency
shift property of DFT.
Theory: In the context of the Discrete Fourier Transform (DFT), there are three important
properties we can verify:
1. Linearity Property
2. Circular Time Shift Property
3. Circular Frequency Shift Property
Let's define each property and then verify them using MATLAB.
1. Linearity Property:
The linearity property of the DFT states:
𝐷𝐹𝑇[𝑥1 (𝑛) + 𝑥2 (𝑛)] = 𝐷𝐹𝑇[𝑥1 (𝑛)] + 𝐷𝐹𝑇[𝑥2 (𝑛)] = 𝑋1 (𝑘) + 𝑋2 (𝑘)
This means the DFT of the sum of two signals is equal to the sum of their individual DFTs.
2. Circular Time Shift Property:
The circular time shift property of the DFT states that if a sequence 𝑥[𝑛] is circularly time-
shifted by m, the DFT of the shifted sequence is:
Where, 𝑋[𝑘] is the DFT of the original sequence𝑥[𝑛] and ((𝑛 − 𝑚))𝑁 denotes a circular time
shift.
3. Circular Frequency Shift Property
The circular frequency shift property of the DFT states that if the DFT of a sequence is circularly
shifted in frequency by m, the result is:
𝑗2𝜋𝑚𝑛
𝐷𝐹𝑇 [𝑥(𝑛)𝑒 𝑁 ] = 𝑋((𝑘 − 𝑚))𝑁
Where, 𝑋[𝑘] is the DFT of the original sequence𝑥[𝑛] and ((𝑘 − 𝑚))𝑁 denotes a circular
frequency shift.
MATLAB program to verify Linearity property
clc;
close all;
x1=input('Enter the samples of x1(n)');
x2=input('Enter the samples of x2(n)');
N1=length(x1);
N2=length(x2);
N=max(N1,N2);
18
Prepared by Dr. Harish M S, AIT
newx1=[x1 zeros(1,N-N1)];
newx2=[x2 zeros(1,N-N2)];
X1=fft(newx1);
X2=fft(newx2);
x_sum=fft(newx1+newx2);
X1_plus_X2=X1+X2;
if abs(x_sum)==abs(X1_plus_X2)
disp('DFT satiesfies the linearity property')
else
disp('DFT doesnot satiesfies the linearity property')
end
MATLAB program to verify circular time shift property
clc;
close all;
x=input('Enter the samples of x(n)');
m=input('enter the value for sfift');
N=length(x);
X=fft(x);
n=0:N-1;
x_shifted=circshift(x,[0,m])
X_shifted=fft(x_shifted);
expected_time_shift=X.*exp(-1*j*2*pi*m*(0:N-1)/N);
if round(expected_time_shift)==round(X_shifted)
disp('DFT satiesfies the time shifting property')
else
disp('DFT doesnot satiesfies the time shifting property')
end
MATLAB program to verify circular frequency shift property
clc;
close all;
x=input('Enter the samples of x(n)');
m=input('enter the value for sfift');
N=length(x);
n=0:N-1;
X=fft(x);
expected_frequency_sfift=circshift(X,[0,m]);
x_frequency_shift=x.*exp(1*j*2*pi*m*n/N);
X_frequency_shift=fft(x_frequency_shift);
if round(X_frequency_shift)==round(expected_frequency_sfift)
disp('DFT satiesfies the frequency shifting property')
else
disp('DFT doesnot satiesfies the frequency shifting property')
end
19
Prepared by Dr. Harish M S, AIT
Expt No 8: Develop decimation in time radix-2 FFT algorithm without using built-in
functions.
Theory: The Decimation-in-Time (DIT) Radix-2 Fast Fourier Transform (FFT) algorithm
recursively reduces the computation of the Discrete Fourier Transform (DFT) of size N into
smaller FFTs. This process divides the input into even and odd-indexed elements, significantly
speeding up the computation compared to a direct DFT calculation. Here is the MATLAB code
for implementing the Decimation-in-Time Radix-2 FFT algorithms without using any built-in
FFT functions.
MATLAB program to implement decimation in time radix-2 FFT algorithm
clc;
close all
x=[1 2 3 4 5 6 7 8];
N = length(x);
if mod(log2(N), 1)~= 0
error('Input length must be a power of 2');
end
if mod(log2(N), 1) ~= 0
error('Input length must be a power of 2');
end
% Bit-reversal reordering
X = bitrevorder(x);
% Iterative FFT computation
for s = 1:log2(N)
m = 2^s;
wm = exp(-2i * pi / m); % Twiddle factor
for k = 1:m:N
for j = 0:(m/2-1)
t = wm^j * X(k+j+m/2);
u = X(k+j);
X(k+j) = u + t; % FFT[k]
X(k+j+m/2) = u - t; % FFT[k + N/2]
end
end
end
disp('DFT of x(n) using Radix-2 DIT FFT algorithm is');
disp(X)
20
Prepared by Dr. Harish M S, AIT
Expt No 9: Design and implementation of digital low pass FIR filter using a window to meet the
given specifications.
Theory: Filters are used to separate the desired signal from the unwanted disturbance. Two
important classes of digital filters based on their impulse response are
Finite impulse response (FIR) filter
Infinite impulse response (IIR) filter
Finite impulse response (FIR) filter: Finite impulse response filter (FIR) are described by
using the difference equation, as
𝑦(𝑛) = 𝑏0 𝑥(𝑛) + 𝑏1 𝑥(𝑛 − 1) + ⋯ . . 𝑏𝑀 𝑥 (𝑛 − 𝑀)
Apply z-transform on both sides we get
𝑌 (𝑧) = 𝑏0 𝑋 (𝑧) + 𝑏1 𝑋(𝑧)𝑧 −1 + ⋯ . . 𝑏𝑀 𝑋 (𝑧)𝑧 −𝑀
M
Y (z)
𝐻 (𝑧 ) = = b0 + b1 z −1 + ⋯ . . bM z −M = ∑ bk z −k
X (z)
k=0
This the general transfer function of FIR filters. FIR filter is also known all zero filter or non
recursive filter and they are inherently stable filter
Characteristics of practical frequency-selective filters
Filters are usually classified according to their frequency domain characteristic as LP, HP, BP, BS
filters. The ideal magnitude response characteristics of these filters are is as shown in below
figure. Theses ideal filters have a constant gain (usually taken as unity gain) in the passband and
zero gain in the stopband. The range of the frequencies where the frequency response takes the
value of one is called passband and the range of frequency where the frequency response is equal
to zero is called stopband of the filter.
21
Prepared by Dr. Harish M S, AIT
These ideal filters having non-casual impulse response and hence these filters are not used for
practical signal processing applications. In order to obtain stable practical, the ideal frequency
response are relaxed by including a transition band between the passband and stopband is as
shown in below figure. And also a small amount of ripple in both passband and stopband are
introduced are known as tolerance.
Let 𝛿1 be the ripple in passband and magnitude varies between 1 ± 𝛿1 in passband. Let 𝛿2 be the
ripple in the stopband. To accommodate a large dynamic range in the graph of frequency
response of the filter, it is a common practice to use logarithmic scale for the magnitude |𝐻(𝜔)|.
Consequently the ripple in the passband is 𝑎𝑝 = 20 log10 𝛿1 decibels and in the stopband 𝑎𝑠 =
20 log10 𝛿2 decibels.
In any filter design problem we specify (1) the maximum passband ripple, (2) the maximum
stopband ripple, (3) the passband edge frequency𝜔𝑝 , and (4) the stopband edge frequency𝜔𝑠 .
Based on these specifications, we can select the filter coefficients {𝑎𝑘 } and {𝑏𝑘 }.
22
Prepared by Dr. Harish M S, AIT
23
Prepared by Dr. Harish M S, AIT
1 𝜔𝑐 −𝑗𝜔𝛼 𝑗𝜔𝑛
= ∫ 𝑒 𝑒 𝑑𝜔
2𝜋 −𝜔𝑐
24
Prepared by Dr. Harish M S, AIT
Depending upon the minimum stopband attenuation, following window are used to design FIR
filter as mentioned in below table.
Table: Transition width and attenuation of different window functions
Name of the Transition Minimum Window function
window width stopband w(n), 0 ≤𝑛 ≤𝑀−1
attenuation
Rectangular 4𝜋 -13 dB w(n) = 1 0≤𝑛≤𝑀−1
∆𝜔 ≥
𝑀
Bartlett 8𝜋 -27 dB 2[𝑛 −
𝑀−1
]
∆𝜔 ≥ 2
𝑀 𝑤(𝑛) = 1 − 0≤𝑛≤𝑀−1
𝑀−1
Hamming 8𝜋 -32dB 2𝜋𝑛
∆𝜔 ≥ w(n) = 0.54 − 0.46cos( ) 0≤𝑛
𝑀 𝑀−1
≤𝑀−1
Hanning 8𝜋 -43dB 1 2𝜋𝑛
∆𝜔 ≥ w(n) = (1 − cos ( ) 0 ≤𝑛 ≤ 𝑀−1
𝑀 2 𝑀−1
Blackman ∆𝜔 -58dB 2𝜋𝑛
𝑤(𝑛) = 0.42 − 0.5 cos ( )
12𝜋 𝑀−1
≥ 4𝜋𝑛
𝑀 + 0.08 cos ( )
𝑀−1
0≤𝑛≤𝑀−1
Design steps
1. Select the suitable window depending upon the minimum stopband attenuation in dB
2. Using the transition width ∆𝑤 of the corresponding window, determine the order of the
2𝜋𝑘
filter M using the formula 𝑀 ≥ .
∆𝑤
25
Prepared by Dr. Harish M S, AIT
26
Prepared by Dr. Harish M S, AIT
hn=hd.*wn';
freqz(hn);
wc
n
27
Prepared by Dr. Harish M S, AIT
Expt No 10: Design and implementation of digital high pass FIR filter using a window to meet
the given specifications.
MATLAB program to design high pass FIR filter using windows
Design a linear phase FIR HPF filter using various windows for the following
specification
28
Prepared by Dr. Harish M S, AIT
wn=hanning(n);
elseif(43<=as<58)
wn=hamming(n);
elseif(as>58)
wn=blackman(n);
end
hn=hd.*wn';
freqz(hn);
wc
n
29
Prepared by Dr. Harish M S, AIT
Expt No11: Design and implementation of digital IIR Butterworth low pass filter to meet the
given specifications.
Theory: Infinite impulse response filter (IIR) are described by using the difference equation, as
𝑦(𝑛) = 𝑏0 𝑥(𝑛) + 𝑏1 𝑥(𝑛 − 1) + ⋯ . . 𝑏𝑀 𝑥 (𝑛 − 𝑀) − 𝑎1 𝑦(𝑛 − 1) − 𝑎2 𝑦(𝑛 − 2) − ⋯ … − 𝑎𝑁 𝑦(𝑛
− 𝑁)
Apply z-transform on both sides we get
𝑌(𝑧) = 𝑏0 𝑋 (𝑧) + 𝑏1 𝑋(𝑧)𝑧 −1 + ⋯ . . 𝑏𝑀 𝑋 (𝑧)𝑧 −𝑀 − 𝑎1 𝑌(𝑧)𝑧 −1 − 𝑎2 𝑌 (𝑧)𝑧 −2 − ⋯ …
− 𝑎𝑁 𝑌(𝑧)𝑧 −𝑁
Y (z) b0 + b1 z −1 + ⋯ . . bM z −M ∑M
k=0 bk z
−k
𝐻(𝑧) = = =
X(z) 1 + a1 z −1 + a2 z −2 + ⋯ … + aN z −N 1 + ∑N
k=1 ak z
−k
Where 𝑎𝑘 and 𝑏𝑘 are coefficient of the filter and 𝐻(𝑧) is the transfer function of the IIR filter.
We know analog filter design is a well developed field. The analog filters are designed using
Butterworth approximation or Chebyshev approximation. In the first step the required digital
filter specifications are converted into analog lowpass filter specifications. With these filter
specifications design the prototype analog lowpass filter is using Butterworth approximation
with cutoff frequency of 1 radian per second, let the transfer function is denoted as 𝐻𝑝 (𝑠). This
analog prototype filter is converted into practical analog filter is denoted as 𝐻𝑎 (𝑠). Finally,
digital IIR filter function 𝐻(𝑧) can easily obtained from practical filter function 𝐻𝑎 (𝑠 ) using
mapping from s-plane to z-plane. To obtain the IIR digital filter function 𝐻(𝑧 ) from 𝐻𝑎 (𝑠 ) we
were using the following method.
1. Bilinear transformation (BLT)
2. Approximation of derivatives
3. Impulse invariance
4. Matched z-transform
MATLAB program to design low pass IIR filter using Butterworth approximation
Design an IIR LPF filter using Butterworth approximation and bilinear transformation
for the following specification
Stopband attenuation 4dB
Passband attenuation 40dB
Stopband frequency 5000rad/sec
Passband frequency 2000rad/sec
Take sampling frequency 10000rad/sec
30
Prepared by Dr. Harish M S, AIT
31
Prepared by Dr. Harish M S, AIT
Expt No 12: Design and implementation of digital IIR Butterworth high pass filter to meet the
given specifications.
MATLAB program to design high pass IIR filter using Butterworth approximation
Design an IIR HPF filter using Butterworth approximation and bilinear transformation
for the following specification
Stopband attenuation 40dB
Passband attenuation 4dB
Stopband frequency 2000rad/sec
Passband frequency 5000rad/sec
Take sampling frequency 10000rad/sec
32