Atme College of Engineering: Lab Manual
Atme College of Engineering: Lab Manual
LAB MANUAL
SEMESTER: VI
Prepared by
Department of EEE,
ATME College of Engineering
INSTITUTIONAL VISION AND MISSION
VISION:
• Development of academically excellent, culturally vibrant, socially responsible and
globally competent human resources.
MISSION:
• To keep pace with advancements in knowledge and make the students
competitive and capable at the global level.
• To create an environment for the students to acquire the right physical, intellectual,
emotional and moral foundations and shine as torchbearers of tomorrow's society.
• To strive to attain ever-higher benchmarks of educational excellence.
Vision:
Mission:
The students will develop an ability to produce the following engineering traits:
PSO1: Apply the concepts of Electrical & Electronics Engineering to evaluate the
performance of power systems and also to control industrial drives using power electronics.
PSO2: Demonstrate the concepts of process control for Industrial Automation, design
models for environmental and social concerns and also exhibit continuous self- learning.
DIGITAL SIGNAL PROCESSING LABORATORY
LIST OF EXPERIMENTS
Exp
Name of the Experiment
No
1. Verification of Sampling Theorem both in time and frequency domains
2. Evaluation of impulse response of a system
3. To perform linear convolution of given sequences
4. To perform circular convolution of given sequences using (a) the convolution summation
formula (b) the matrix method and (c) Linear convolution from circular convolution with zero
padding.
5. Computation of N –point DFT and to plot the magnitude and phase spectrum.
6. Linear and circular convolution by DFT and IDFT method.
7. Solution of a given difference equation.
8. Calculation of DFT and IDFT by FFT
9. Design and implementation of IIR filters to meet given specification (Low pass, high pass, band
pass and band reject filters)
10. Design and implementation of FIR filters to meet given specification (Low pass, high pass,
band pass and band reject filters) using different window functions
11. Design and implementation of FIR filters to meet given specification (Low pass, high pass,
band pass and band reject filters) using frequency sampling technique.
12. Realization of IIR and FIR filters
TEXT BOOKS:
1. Introduction to Digital Signal Processing, Jhonny R. Jhonson, Pearson, 1 st Edition, 2016.
2. . Digital Signal Processing – Principles, Algorithms, and Applications, Jhon G. ProakisDimitris
G. Manolakis, Pearson 4th Edition, 2007.
3. Digital Signal Processing, A.NagoorKani, McGraw Hill, 2 nd Edition, 2012.
COURSE OUTCOMES
Exp
Name of the Experiment Page no.
no
1. Verification of Sampling Theorem both in time and frequency domains 1
2. Evaluation of impulse response of a system 3
3. To perform linear convolution of given sequences 5
4. To perform circular convolution of given sequences using (a) the convolution
summation formula (b) the matrix method and (c) Linear convolution from 7
circular convolution with zero padding.
5. Computation of N –point DFT and to plot the magnitude and phase spectrum. 10
6. Linear and circular convolution by DFT and IDFT method. 12
7. Solution of a given difference equation. 15
8. Calculation of DFT and IDFT by FFT 17
9. Design and implementation of IIR filters to meet given specification (Low pass,
20
high pass, band pass and band reject filters)
10. Design and implementation of FIR filters to meet given specification (Low pass,
24
high pass, band pass and band reject filters) using different window functions
11. Design and implementation of FIR filters to meet given specification (Low pass,
31
high pass, band pass and band reject filters) using frequency sampling technique.
12. Realization of IIR and FIR filters 35
DIGITAL SIGNAL PROCESSING LABORATORY 18EEL67
Experiment no. 1
Theory: In digital signal processing, the sampling theorem is the basic bridge between
continuous-time signals and discrete-time signals.
Statement: A continuous time signal can be represented in its samples and can be recovered
back when sampling frequency fs is greater than or equal to the twice the highest frequency
component of message signal i.e.
fS≥2fm
Program:
clc;
clear;
f=50
t=0:0.00001:0.04
y=sin(2*pi*f*t);
subplot(3,3,1);
plot(t,y);
y3=sin(2*pi*f*n/fs3);
subplot(3,3,6);
stem(n,y3);
hold on
subplot(3,3,7);
plot(n,y3);
Fig. 1.1: waveforms for sampling frequency = 50Hz, 500Hz and 1000 Hz.
Outcome: student will be able to give physical interpretation of sampling theorem in time and
frequency domains
Experiment no. 2
Objectives: to verify the response of a system for a impulse input using simulation tool.
Theory: The impulse response of a system is the output of the system when the input signal is an
impulse function.
The impulse response and frequency response are two attributes that are useful for characterizing
linear time-invariant (LTI) systems.
Program:
clc;
clear all;
b=input('enter the coefficients of x(n),x(n-1)-----');
a=input('enter the coefficients of y(n),y(n-1)----');
N=input('enter the number of samples of impulse response ');
[h,t]=impz(b,a,N);
disp(h);
stem(t,h);
Output Windows
Fig. 2.2: output waveform of the impulse response of the given system
Experiment 3
Theory: convolution relates the input signal and impulse response of the system to the output of
the system. Convolution is a mathematical operation which is used to express the input-output
relationship of an LTI system.
Linear convolution is the basic operation to calculate the output for any linear time
invariant system given its input and its impulse response. Linear convolution is given by
y(n) = x(k)h(n − k)
k =−
1 2 3 5 7 8 9
1 1 2 3 5 7 8 9
2 2 4 6 10 14 16 18
3 3 6 9 15 21 24 27
y(n) = (1 4 10 17 26 37 46 42 27)
Program
clc;
clear;
x1=input('enter the first sequence');
subplot(3,1,1);
stem(x1);
title('plot of the first sequence');
x2=input('enter 2nd sequence');
subplot(3,1,2);
stem(x2);
title('plot of 2nd sequence');
f=conv2(x1,x2);
disp('output of linear convolution is');
disp(y);
Output Windows
Experiment 4
Objectives: to verify the circular convolution by various methods using simulation tool.
Program:
clc;
clear;
x1=input('enter x1(n):');
n1=length(x1);
x2=input('enter x2(n):');
n2=length(x2);
N=max(n1,n2);
T=1:N;
x1=[x1 zeros(1,N-n1)];
x2=[x2 zeros(1,N-n2)];
y=zeros(1,N);
for m=1:N
for n=1:N
i=m-n+1;
if(i<=0)
i=N+i;
end
y(m)=y(m)+x1(n)*x2(i);
end
end
disp(y);
stem(y);
Output Windows
enter x1(n):[0 1 2 3]
enter x2(n):[2 1 2 1]
circular convolution of the given sequences is
8 10 8 10
Fig. 4.1: Output waveform for the given sequence using convolution summation formula.
Program:
clc;
clear;
a=input('Enter the first sequence x1(n):');
b=input('Enter the first sequence x2(n):');
c=circshift(a,1);
d=circshift(a,2);
e=circshift(a,3);
m=[a c d e];
y=m*b;
disp(m);
disp('Circular Convolution of x1(n) & x2(n) is:');
disp(y);
n=0:3;
stem(n,y);
title('circulation convolution using matrix method');
Output Windows
Enter the first sequence x1(n):[2;1;2;1]
Enter the first sequence x2(n):[1;2;3;4]
2 1 2 1
1 2 1 2
2 1 2 1
1 2 1 2
Circular Convolution of x1(n) & x2(n) is:
14
16
14
16
Fig. 4.2: Output waveform for the given sequence using matrix method
Result: Circular Convolution is verified for the given sequence using various methods.
Outcome: student will be able to perform circular convolution of given sequences using various
methods
Experiment 5:
Computation of N – point DFT and to Plot the Magnitude and Phase
Spectrum
Aim: To perform N-point DFT computation and plot the magnitude and phase spectrum.
Objectives: To explain the use of MATLAB software in evaluating the DFT of given sequence
Theory: DFT is the process of conversation of time domain continuous signal into frequency
domain discrete signal. DFT of an N-point sequence is given by
N −1 − j2π nk
X(k) = x(n)e
n =0
N
1 1 1 1 0 6
1 − j − 1 j 1 − 2 + j2
X(k) = * =
1 − 1 1 − 1 2 − 2
1 j − 1 − j 3 − 2 − j2
X(k)=(6,-2+j2,-2,-2-j2)
Program:
clc;
close all;
clear all;
xn = input('enter the sequence x(n) =');
xn=xn';
N=length(xn);
n=0:N-1;
for k=0:N-1
Xk(k+1)=exp(-j*2*pi*k*n/N)*xn;
end
disp('DFT of the given sequence is:');
disp(Xk);
k = 0:N-1;
disp('magnitude of the sequence is:')
disp(abs(Xk))
subplot(2,1,1)
stem(k,abs(Xk));
xlabel('k');
ylabel('|X(k)|');
title('Magnitude spectrum');
subplot(2,1,2);
stem(k,angle(Xk));
disp('phase angle of the sequence in radians is:');
disp(angle(Xk));
xlabel('k');
ylabel('<X(k)');
title('Phase spectrum');
Output Window:
enter the sequence x(n) =[0 1 2 3]
DFT of the given sequence is:
6.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 - 0.0000i -2.0000 - 2.0000i
magnitude of the sequence is:
6.0000 2.8284 2.0000 2.8284
phase angle of the sequence in radians is:
0.00000 2.35619 -3.14159 -2.35619
Result: N-point DFT was computed for given signal and its magnitude and phase spectrum was
plotted.
Outcome: student will be able to Compute DFT and find its magnitude and phase angle
spectrum
Experiment 6:
Linear and circular convolution by DFT and IDFT method.
Aim: To perform Linear & Circular convolution by DFT & IDFT Method.
Objective: to verify the Linear and circular convolution by DFT & IDFT method using
simulation tool
Theory: DFT and IDFT method is also known as stockham's method used to find the Circular
convolution of the given sequences.
y(n) = x(n) N h(n)
clc;
clear all;
close all;
xn = input('enter the first sequence x(n) = ');
hn = input('enter the second sequence h(n) = ');
N = max(length(xn),length(hn));
Xk = fft(xn,N);
Hk = fft(hn,N);
Yk = Xk.*Hk;
yn = ifft(Yk,N);
disp('Circular convolution of x(n) and h(n) =');
disp(yn);
subplot(2,2,1);
stem(xn);
xlabel('n');
ylabel('x(n)');
title('plot of x(n)');
subplot(2,2,2);
stem(hn);
xlabel('n');
ylabel('h(n)');
title('plot of h(n)');
subplot(2,2,3);
stem(yn);
xlabel('n');
Department of EEE, ATMECE, Mysore Page 12
DIGITAL SIGNAL PROCESSING LABORATORY 18EEL67
ylabel('y(n)');
title('Circular convolution Output');
Output Screen
Enter the first sequence x(n) = [1 2 3 4]
Enter the second sequence h(n) = [4 5 6 1]
Circular convolution of x(n) and h(n) = 44 40 32 44
Fig. 6.1: Input and output waveforms of the given sequence using DFT and IDFT method.
xlabel('n');
ylabel('x(n)');
title('plot of x(n)');
subplot(2,2,2);
stem(hn);
xlabel('n');
ylabel('h(n)');
title('plot of h(n)');
subplot(2,2,3);
stem(yn);
xlabel('n');
ylabel('y(n)');
title('Convolution Output');
Output window:
Enter the first sequence x(n) = [1 5 7 8]
Enter the second sequence h(n) = [3 1 5 6]
'Linear Convolution of given sequences = 3 16 31 62 73 82 48
Fig. 6.2: Input and output waveforms of the given sequence using DFT and IDFT method
Result: Linear & circular convolution was computed using DFT and IDFT method.
Outcomes: student will be able to perform linear & circular convolution using DFT & IDFT
method
Experiment 7:
Solution of a given difference equation
Theory: An LTI discrete system can also be described by a linear constant coefficient difference
equation of the form.
N M
a k y(n − k) = b m x(n − m)
K =0 m =0
n
Example:
let y(n) - 3 y(n − 1) + 1 y(n − 2) = x(n)
2 2
( )
Given x(n) = 1 u(n)
4
n
Program:
clc;
clear;
b=input('enter the co-effencient of x(n):');
a=input('enter the co-effencient of y(n):');
y=input('enter the initial conditions:');
Fig. 7.1: Waveform for the solution of the given difference equation
Outcomes: student will be able to find the solution of difference equation using simulation tool.
Experiment 8:
Calculation DFT & IDFT by FFT
Theory: as discussed earlier DFT is the process of conversation of time domain continuous
signal into frequency domain discrete signal. DFT of an N-point sequence is given by
N −1 − j2π nk
X(k) = x(n)e
n =0
N
IDFT is the process of conversation of frequency domain discrete signal into time domain
continuous signal. IDFT of an N-point sequence is given by
N −1 j2π nk
x(n) = X(k)e
k =0
N
Fig. 8.1: Magnitude and phase angle plot for 8-point sequence.
Program:
clc;
clear all;
N=input('Enter the value of N: ');
X =input('Enter the first sequence=');
x = ifft(X,N);
disp('IDFT of the given sequence is');
disp(x);
stem(x);
title('IDFT of given sequence');
Fig. 8.2: output waveform of the IDFT for the given sequence
Outcomes: student will be able to compute DFT and IDFT using FFT command.
Experiment 9:
Design and implementation of IIR filters to meet given specification
Theory: filer enhances a wanted signal and eliminates to unwanted signals. IIR filters are digital
filters with infinite impulse response. They have the feedback and are known as recursive digital
filters therefore. IIR filters have much better frequency response than FIR filters of the same
order. There are mainly two types of IIR filter, Butterworth and Chebyshev filter.
Design procedure:
Finding the value of N:
−KP
10 10 − 1
log − K
S
10 10 − 1
N=
Ω
2log P
ΩS
Finding the poles of the transfer function
SK = 1θ K Where k=0,1,2,3…2N-1
πk π π
θK = + +
N 2N 2
Finding Transfer function:
1
H N (s) =
(s − s k )
LHP only
Example: Design a low pass Butterworth filter to satisfy the following specifications;
Pass band cutoff = 500 Hz; Pass band ripple = 3.01 db;
Stop band cutoff = 750 Hz; Stop band ripple = 15 db;
Program:
Output Window
Enter the Pass band frequency in Hz = 500
Enter the Stop band frequency in Hz = 750
Enter the Sampling frequency in Hz = 2000
Enter the Pass band ripple in db:3.01
Enter theStop band ripple in db:15
order of the filter N =
4
num/den =
0.0022316 z^4 + 0.0089263 z^3 + 0.013389 z^2 + 0.0089263 z + 0.0022316
----------------------------------------------------------------------
z^4 - 2.6932 z^3 + 2.8684 z^2 - 1.4042 z + 0.26461
Fig. 9.2: Magnitude and phase angle curve of low pass filter
Example: Design a high pass Butterworth filter to satisfy the following specifications;
Pass band cutoff = 32 Hz; Pass band ripple = 2 db;
Stop band cutoff = 16 Hz; Stop band ripple = 20 db;
clc;
clear all;
close all;
rp=input('Enter the pass band ripple:rp=');
rs=input('Enter the stop band ripple:rs=');
fp=input('Enter the pass band freq:wp=');
fs=input('Enter the stop band freq:ws=');
Fs=input('Enter the sampling freq fs=');
wp=2*fp/Fs;
ws=2*fs/Fs;
Up = 2*tan(wp/2);% Prewrapped frequency
Us = 2*tan(ws/2);
[N,wn]=buttord(Up,Us,rp,rs,'s');
Disp(‘ Order of the filter is: ‘);
disp(N);
disp('freq resp of iir high pass filter is:');
[b,a]=butter(N,wn,'high','s');
disp('Normalized cut off frequency = ');
disp(wn);
[num, den] = butter(N,wn,'high','s'); % analog filter transfer
[b,a] = bilinear(num, den,1); % conversion of analog filter to digital filter
Fig. 9.3: Magnitude and phase angle curve of high pass filter
Result: IIR filter was designed was verified using simulation tool.
Outcomes: students will be able to design and implement the IIR Filter.
Experiment 10:
Design and Implementation of FIR Filters Using Different Window Functions
Aim: To Design and implement FIR filter using various window techniques.
Problem:
Program:
clc;
clear all;
Rp=input('Enter the passband attenuation in dB: ');
Rs=input('Enter the stopband attenuation in dB: ');
fp=input('Enter the passband frequency in Hz: ');
fs=input('Enter the stopband frequency in Hz: ');
Fs=input('Enter sampling frequency in Hz: ');
Wp=2*pi*fp/Fs;
Ws=2*pi*fs/Fs;
%Rectangular Window
if Rs<=21
M = ceil(4*pi/(Ws-Wp))+1
y = rectwin(M);
figure, subplot(2,1,1),stem(y);
title('Rectangular Window');
end
%Bartlett Window
Department of EEE, ATMECE, Mysore Page 24
DIGITAL SIGNAL PROCESSING LABORATORY 18EEL67
if Rs<=25 &Rs>21
M =ceil(8*pi/(Ws-Wp)) +1
y=bartlett(M);
figure, subplot(2,1,1),stem(y);
title('Bartlett Window');
end
%Hanning Window
if Rs<=44 &Rs>25
M =ceil(8*pi/(Ws-Wp)) +1
y=hanning(M);
figure, subplot(2,1,1),stem(y);
title('Hanning Window');
end
%Hamming Window
if Rs<=53 &Rs>44
M = ceil(8*pi/(Ws-Wp)) +1
y=hamming(M);
figure, subplot(2,1,1),stem(y);
title('Hamming Window');
end
% Blackman Window
if Rs<=74 &Rs>53
M = ceil(12*pi/(Ws-Wp))+1
y=blackman(M);
figure, subplot(2,1,1),stem(y);
title('Blackman Window');
end
wc = (Ws +Wp)/2
%Ideal lowpass filter
alpha = (M-1)/2
n = [0 : 1 : (M-1)];
m = n - alpha + eps;
hd = sin(wc*m)./(pi*m);
h = hd.*y';
subplot(2,1,2), stem(h);
title('Impulse response of FIR filter');
%w = logspace(-1,1);
figure, freqz(h)
title('Frequency response of FIR lowpass filter')
Output Window:
Enter the passband attenuation in dB: 0.01
Enter the stopband attenuation in dB: 0.02
Enter the passband frequency in Hz: 1000
Enter the stopband frequency in Hz: 1500
Enter sampling frequency in Hz: 8000
M = 33
Department of EEE, ATMECE, Mysore Page 25
DIGITAL SIGNAL PROCESSING LABORATORY 18EEL67
wc = 0.98175
alpha = 16
Fig. 10.1: Rectangular window and Impulse response curve of FIR filter
Fig. 10.2: Magnitude and phase angle curve of lowpass FIR filter
Problem:
Design a bandpass filter with the given specifications:
Lower stopband edge = 0.2π
Lower Passband edge = 0.35π
Upper passband edge = 0.65π
Upper stopband edge = 0.8π
Passband attenuation = 1db
Stopband attenuation = 60db
Program:
clc;
clear all;
Rp=input('Enter the passband attenuation in dB: ');
Rs=input('Enter the stopband attenuation in dB: ');
Wp=input('Enter the passband frequency in pi rad: ');
Ws=input('Enter the stopband frequency in pi rad: ');
tr_width = min((Wp(1)-Ws(1)),(Ws(2)-Wp(2)))
%Rectangular Window
if Rs<=21
M = ceil(4*pi/tr_width)+1
y = rectwin(M);
figure, subplot(2,1,1),stem(y);
title('Rectangular Window');
end
%Bartlett Window
if Rs<=25 &Rs>21
M =ceil(8*pi/tr_width) +1
y=bartlett(M);
figure, subplot(2,1,1),stem(y);
title('Bartlett Window');
end
%Hanning Window
if Rs<=44 &Rs>25
M =ceil(8*pi/tr_width) +1
y=hanning(M);
figure, subplot(2,1,1),stem(y);
title('Hanning Window');
end
%Hamming Window
if Rs<=53 &Rs>44
M = ceil(8*pi/tr_width) +1
y=hamming(M);
figure, subplot(2,1,1),stem(y);
title('Hamming Window');
end
% Blackman Window
if Rs<=74 &Rs>53
M = ceil(12*pi/tr_width)+1
y=blackman(M);
figure, subplot(2,1,1),stem(y);
title('Blackman Window');
end
wc1 = (Ws(1) +Wp(1))/2
wc2 = (Ws(2)+Wp(2))/2
%Ideal bandpass filter
alpha = (M-1)/2
n = [0 : 1 : (M-1)];
m = n - alpha + eps;
hd = (sin(wc2*m)./(pi*m))- (sin(wc1*m)./(pi*m));
h = hd.*y';
subplot(2,1,2), stem(h);
title('Impulse response of FIR filter');
%w = logspace(-1,1);
figure, freqz(h)
title('Frequency response of FIR Bandpass filter')
Output window
Enter the passband attenuation in dB: 1
Enter the stopband attenuation in dB: 60
Enter the passband frequency in pi rad: [0.35*pi 0.65*pi]
Enter the stopband frequency in pi rad: [0.2*pi 0.8*pi]
tr_width = 0.47124
M = 81
wc1 = 0.86394
wc2 = 2.2777
alpha = 40
Fig. 10.3: Blackman window and Impulse response curve of FIR filter
Fig. 10.4: Magnitude and phase angle curve of bandpass FIR filter
Note:
1. For highpass filter change the hd line in lowpass filter program to line specified below
hd = sin(pi*m)./(pi*m)- sin(wc*m)./(pi*m)
2. For bandstop filter change the hd line in bandpass filter program to line specified below
hd = (sin(wc1*m)./(pi*m)) + (sin(pi*m)./(pi*m)) - (sin(wc2*m)./(pi*m))
Outcomes: students will be able to design and implement the FIR Filter using various windows.
Experiment 11:
Design and Implementation of FIR Filters using Frequency Sampling
Technique
Aim: To design and implement FIR filters using frequency sampling technique to meet given
specifications
Problem: Design an FIR low-pass filter for the given specification using frequency
sampling approach
Wp = 0.28π; Pass band attenuation = 0.25db;
Ws = 0.57π; stop band attenuation = 20db;
M = 7;
alpha = (M-1)/2;
l = 0:M-1
wl = (2*pi/M)*l
%Hrs = [1,1,1,zeros(1,15),1,1]; %Ideal Amp Res sampled
Hrs = [1,1,0,0,0,0,1]
Hdr = [1,1,0,0];%Ploting ideal response i;e 1 in passband and 0 in stopband
wdl = [0,0.42,0.42,1]; %Ideal Amp Res for plotting
k1 = 0:floor((M-1)/2)
k2 = floor((M-1)/2)+1:M-1
angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)]
H = Hrs.*exp(j*angH)
h = real(ifft(H,M))
subplot(2,2,1)
plot(wl(1:4)/pi,Hrs(1:4),'o',wdl,Hdr)
title(„Frequency samples M=7)
fvtool(h)
Output:
l=[0123456]
wl = [0 0.8976 1.7952 2.6928 3.5904 4.4880 5.3856]
Hrs = [1 1 0 0 0 0 1]
k1 = [0 1 2 3]
k2 = [4 5 6]
angH = [0 -2.6928 -5.3856 -8.0784 8.0784 5.3856 2.6928]
H=
[ 1.0000 + 0.0000i -0.9010 - 0.4339i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i -0.9010 + 0.4339i ]
h = [-0.1146 0.0793 0.3210 0.4286 0.3210 0.0793 -0.1146]
Output Waveform
Design the FIR high-pass filter with following specifications frequency sampling technique.
Stop band edge: ws = 0.6π, As = 50db;
Pass band edge: wp = 0.8π, Rp = 1db;
M = 10;
alpha = (M-1)/2;
l = 0:M-1
wl = (2*pi/M)*l
%Hrs = [1,1,1,zeros(1,15),1,1]; %Ideal Amp Res sampled
Hrs = [0,0,0,0,1,1,1,0,0,0]
Hdr = [0,0,1,1];%Ploting ideal response i;e 1 in passband and 0 in stopband
wdl = [0,0.6,0.8,1]; %Ideal Amp Res for plotting
k1 = 0:floor((M-1)/2)
k2 = floor((M-1)/2)+1:M-1
angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)]
H = Hrs.*exp(j*angH)
h = real(ifft(H,M))
subplot(2,2,1)
plot(wl(1:6)/pi,Hrs(1:6),'o',wdl,Hdr)
title('Frequency samples M=10')
fvtool(h)
Output:
l = [0 1 2 3 4 5 6 7 8 9]
k1 = [0 1 2 3 4]
k2 = [5 6 7 8 9]
angH = [0 -2.8274 -5.6549 -8.4823 -11.3097 14.1372 11.3097 8.4823 5.6549 2.8274]
H = Columns 1 through 7
[0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.3090 + 0.9511i
0.0000 + 1.0000i 0.3090 - 0.9511i]
Columns 8 through 10
[0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i]
h = [0.0618 -0.1618 0.2000 -0.1618 0.0618 0.0618 -0.1618 0.2000 -0.1618 0.0618]
Output Waveform:
Result: FIR Filter design was verified using frequency sampling technique.
Outcomes: students will be able to design and implement the FIR Filter using frequency
sampling technique.
Experiment 12:
Realization of IIR and FIR Filters
Theory:
The realization of a discrete filter can be done in hardware or in software. In either case, the
implementation of the transfer function H(z) of a discrete filter requires delays, adders, and
constant multipliers as actual hardware or as symbolic components. Figure depicts the operation
of each of these components as block diagrams.
Program:
function [b0,B,A] = dir2cas(b,a)
%compute gain coefficients
b0 = b(1);
b = b/b0;
a0 = a(1);
a = a/a0;
b0 = b0/a0;
M = length(b);
N = length(a);
if N > M
b = [b zeros(1,N-M)]
elseif M > N
a = [a zeros(1,M-N)]
N= M;
else
NM = 0;
end
K = floor(N/2)
B = zeros(K,3)
A = zeros(K,3)
if K*2 == N
b = [b 0]
a = [a 0]
end
broots = cplxpair(roots(b))
aroots = cplxpair(roots(a))
fori = 1:2: 2*K
Brow = broots(i : 1 : i+1,:)
Brow = real(poly(Brow))
B(fix((i+1)/2),:) = Brow
Arow = aroots(i : 1 : i+1,:)
Arow = real(poly(Arow))
A(fix((i+1)/2),:) = Arow
Department of EEE, ATMECE, Mysore Page 36
DIGITAL SIGNAL PROCESSING LABORATORY 18EEL67
end
%Realization of IIR filters direct to cascade structure
b = [1 -3 11 -27 18]
a = [16 12 2 -4 -1]
[b0,B,A] = dir2cas(b,a)
%Realization of IIR filters cascade to direct structure
[b,a] = cas2dir(b0,B,A)
Output:
%direct to cascade realization
b0 =[0.0625]
B = [1.0000 0.0000 9.0000
1.0000 -3.0000 2.0000]
A = [1.0000 1.0000 0.5000
1.0000 -0.2500 -0.1250]
%cascade to direct realization
b = [0.0625 -0.1875 0.6875 -1.6875 1.1250]
a = [1.0000 0.7500 0.1250 -0.2500 -0.0625]
Problem;
Determine the coefficients km of the lattice filter corresponding to FIR filter described by
the system function:
.H(Z)=1+2Z-1+0.33Z-2
Program:
b = [1 2 1/3]
k = tf2latc (b)
Output:
k =[1.5000 0.3333]
Viva questions: