0% found this document useful (0 votes)
75 views

DSP LAB MANUAL-2024-5th Semester

Uploaded by

ece1year2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

DSP LAB MANUAL-2024-5th Semester

Uploaded by

ece1year2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

DEPARTMENT OF ELECTRONICS &

COMMUNICATION

Digital Signal Processing Laboratory

(PRACTICAL COMPONENT OF IPCC)

(BEC502))

V SEMESTER
Course Objective

1. Preparation: To prepare students with fundamental knowledge/ overview in the


field of Digital Signal Processing
2. Core Competence: To equip students with a basic foundation of Signal Processing
by delivering the basics of Discrete Fourier Transforms, their properties, efficient
computations & the design of digital filters.

Course Specific Outcome

PSO1 PSO2
C307.1 3 3
C307.2 3 3
C307.3 3 3
C307.4 3 3
C307.5 3 3
C307.6 3 3
C307 3 3

At the end of the program students will have

PSO1: Ability to absorb and apply fundamental knowledge of core Electronics and Communication
Engineering in the analysis, design and development of Electronics Systems as well as to
interpret and synthesize experimental data leading to valid conclusions

PSO2: Ability to solve complex Electronics and Communication Engineering problems, using latest
hardware and software tools, along with analytical and managerial skills to arrive at appropriate
solutions, either independently or in team

RUBRICS FOR LAB

• FOR 25 MARKS

Sl.No. DESCRIPTION MARKS Scaled


marks

1. CONTINUOUS EVALUATION 35 15

• Observation write up & punctuality 5


• Conduction of experiment and output 15.0
• Viva voce 5
• Record write up 10.0
2. INTERNAL TEST 50 10
INDEX

Student Name: Max Marks: ……..

USN:

Revised Bloom’s
SL.
NAME OF THE EXPERIMENT Taxonomy (RBT)
NO
Level

PRACTICAL COMPONENT OF IPCC


Program to generate the following discrete time signals. a) Unit L2, L3, L4
1
sample sequence, b)Unit step sequence, c) Exponential sequence,
d)Sinusoidal sequence, e) Random sequence
2 Program to perform the following operations on signals. a) Signal L2, L3, L4
addition, b) Signal multiplication, c)Scaling, d) Shifting, e)Folding
3 Program to perform convolution of two given sequences (without L2, L3, L4
using built-in function) and display the signals.
Consider a causal system y(n) = 0.9y(n-1)+x(n). a) Determine H(z) L2, L3, L4
4
and sketch its pole zero plot. b) Plot |H(ejω)| and ∠ H(ejω) c)
Determine the impulse response h(n).
5 Computation of N point DFT of a given sequence (without using L2, L3, L4
built-in function) and to plot the magnitude and phase spectrum.
6 Using the DFT and IDFT, compute the following for any two given L2, L3, L4
sequences a)Circular convolution b) Linear convolution
7 Verification of Linearity property, circular time shift property & L2, L3, L4
circular frequency shift property of DFT.
8 Develop decimation in time radix-2 FFT algorithm without using L2, L3, L4
built-in functions
9 Design and implementation of digital low pass FIR filter using a L2, L3, L4
window to meet the given specifications
10 Design and implementation of digital high pass FIR filter using a L2, L3, L4
window to meet the given specifications
11 Design and implementation of digital IIR Butterworth low pass filter L2, L3, L4
to meet the given specifications.
12 Design and implementation of digital IIR Butterworth high pass filter L2, L3, L4
to meet the given specifications
Experiment – 1

Aim: 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:

Signal is a time varying physical phenomenon which is intended to convey information. Signal is
a function of one or more independent variables, which contain some information.

Example: voice signal, video signal, signals on telephone wires etc.

Note: Noise is also a signal, but the information conveyed by noise is unwanted hence it is
considered as undesirable.

System is a device or combination of devices, which can operate on signals and produces
corresponding response. Input to a system is called as excitation and output from it is called as
response. For one or more inputs, the system can have one or more outputs.
// Unit Sample Sequence
clear;
clc;
close;
L =4; //upper Limit
n =-L:L;
x =[zeros(1,L),1,zeros(1,L)];
b =gca();
b.y_location ="middle";
plot2d3('gnn',n,x)
a=gce();
a.children(1).thickness =4;
xtitle('Unit Sample Signal','n','x[n]');
// Unit Step Signal
clear;
clc;
close;
L=100;// Upper Limit
n=-L:L;
x=[zeros(1,L),ones(1,L+1)];
a=gca();
a.y_location= "middle";
plot2d3('gnn',n,x)
title( ' Unit Step Signal')
xlabel('n');
ylabel('x[n]');

//Discrete Exponential Sequence


clear;
clc;
clf;
close;
L=10; // Upper limit
n=0:L;
x =30.*exp(n);
b=gca();
b.y_location='middle';
plot2d3('gnn',n,x)
a=gce();
a.children(1).thickness=2;
xtitle('Exponential Sequence');

// Discrete Sinusoidal Sequence


clear;
clc;
clf;
close;
L=25; // Upper limit
n=-L:L;
x =sin(n);
b=gca();
b.y_location='middle';
plot2d3('gnn',n,x)
a=gce();
a.children(1).thickness=2;
xtitle('Sine Sequence');

// Discrete Random Sequence


clear;
clc;
clf;
close;
L=25; // Upper limit
n=-L:L;
x =rand(n);
b=gca();
b.y_location='middle';
plot2d3('gnn',n,x)
a=gce();
a.children(1).thickness=2;
xtitle('Random Sequence');
Experiment – 2
Aim: Program to perform the following operations on signals. a) Signal addition, b) Signal
multiplication, c) Scaling, d) Shifting, e)Folding
Theory :
// Addition of Signals
clc ;
clear ;
n1=[2 3 5 6 7]
n2=[3 4 -5 -6 4]
n3=n1+n2
disp('Addition output',n3)

Output:

Addition output : 5. 7. 0. 0. 11.

// Multiplication of Signals
clc ;
clear ;
n1=[2 3 5 6 7]
n2=[3 4 -5 -6 4]
n3=n1.*n2
disp('Multiplication output',n3)

Multiplication output: 6. 12. -25. -36. 28.

// Scaling of Signals
i=0:5;
n1=0.5*(i);
subplot(3,1,1);
plot2d3(i,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Signal1',"fontsize" ,4);
subplot(3,1,2);
plot2d3(2*i,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Expanded Signal',"fontsize" ,4);
subplot(3,1,3);
plot2d3(0.5*i,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Compressed Signal',"fontsize" ,4);
// Shifting

i=0:15;
n1=2*i;
subplot(3,1,1);
plot2d3(i,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Signal1',"fontsize" ,4);
subplot(3,1,2);
plot2d3(i-2,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Left Shift',"fontsize" ,4);
subplot(3,1,3);
plot2d3(i+3,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Right shift',"fontsize" ,4);

// Folding of Signals
clc ;
clf;
i=0:5;
n1=0.5*(i+2);

subplot(2,1,1);
plot2d3(i,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Signal1',"fontsize" ,4);

subplot(2,1,2);
plot2d3(-i,n1);
xlabel('n',"fontsize",4);
ylabel('Amplitude',"fontsize",4);
title('Folded Signal',"fontsize" ,4);
Experiment –3
Aim: Program to perform convolution of two given sequences (without using built-in function) and
display the signals.

Theory:
// A GENERALAZED CONVOLUTION COMPUTING CODE IN MATLAB WITHOUT USING
MATLAB BUILTIN FUNCTION conv(x,h)
clc;
clear;

x=[1 2 3 4];
h=[1 2 3 4];
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
disp(Y)

Output:

Y: 1. 4. 10. 20. 25. 24. 16.


Experiment – 4
Aim: Consider a causal system y(n) = 0.9y(n-1)+x(n).
a) Determine H(z) and sketch its pole zero plot.
b) Plot |H(ejω)| and ∠ H(ejω)
c) Determine the impulse response h(n).

// Experiment number 4
clear ;
clc ;
close;

s=poly(0,'s');
n=[s];
d=[s-0.9];
h=syslin('c',n./d);
plzr(h);
figure
gainplot(h)
figure
phaseplot(h)

disp('Length of impulse response required')


N=6;
disp('Co-efficients of X')
b=[1]
disp('Co-efficients of y')
a=[1 -0.9]
x=[1,zeros(1,N-1)];
disp('Impulse
response')
h=filter(b,a,x)
disp(h)
Impulse response

1. 0.9 0.81 0.729 0.6561 0.59049


Experiment – 5

Aim: Computation of N point DFT of a given sequence (without using built-in function) and to
plot the magnitude and phase spectrum

Theory: In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of
equally-spaced samples of a function into a same-length sequence of equally-spaced samples of
the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency.
The interval at which the DTFT is sampled is the reciprocal of the duration of the input sequence.
An inverse DFT is a Fourier series, using the DTFT samples as coefficients
of complex sinusoids at the corresponding DTFT frequencies. It has the same sample-values as
the original input sequence. The DFT is therefore said to be a frequency domain representation of
the original input sequence. If the original sequence spans all the non-zero values of a function, its
DTFT is continuous (and periodic), and the DFT provides discrete samples of one cycle. If the
original sequence is one cycle of a periodic function, the DFT provides all the non-zero values of
one DTFT cycle.

Example
clc
close
clf
i=sqrt(-1);
disp('The Input sequence is')
xn=[1 2-i -i -1+2*i]
ln=length(xn);
xk=zeros(1,ln);
i=sqrt(-1);
for k=0:ln-1
for n=0:ln-1
xk(k+1)=xk(k+1)+(xn(n+1)*exp((-i)*2*%pi*k*n/ln));
end
end
disp('The DFT sequence is',xk)

n=0:1:ln-1;
xbs=abs(xk);
subplot(121),plot2d3(n,xbs);
xlabel('Length');
ylabel('Magnitude of X(k)');
title('Magnitude Spectrum');
an=phasemag(xk);
subplot(122),plot2d3(n,an);
xlabel('Length');
ylabel('Phase of X(k)');
title('Phase Spectrum');

Output: The DFT sequence is

2. -2. - 2.i 8.882D-16 - 2.i 4. + 4.i

xbs =

2. 2.8284271 2. 5.6568542

an =

0. -135. -90. 45.


Experiment – 6

Aim: Using the DFT and IDFT, compute the following for any two given sequences a) Circular
convolution b) Linear convolution

Code for Circular Convolution


clc;
clear ;

disp('Circular convolution program')


x=[1 2 0 0]
m=length(x);
h=[3 5 4 0]
n=length(h);
disp('circular convolution of x(n) & h(n) is y(n):')
y1=fft(x,-1);
y2=fft(h,-1);
y3=y1.*y2;
y=fft(y3,1);
disp(y)

circular convolution of x(n) & h(n) is y(n):

3. 11. 14. 8.

//Code for Linear Convolution using DFT


clc;
clear ;
clf;
disp('Linear convolution using DFT')
x=[1 2 -5 2]
m=length(x);
h=[3 -5 4 1]
n=length(h);
L=max(length(x),length(m))-1;
z=conv(x,h)
disp(z,'(Linear convolution of x(n) & h(n) Using In built formula:')
X=[x,zeros(1,L)]
H=[h,zeros(1,L)]
//disp(X);
//disp(H);
y1=fft(X,-1);
y2=fft(H,-1);
y3=y1.*y2;
y=fft(y3,1);
disp(y,'Linear convolution of x(n) & h(n) is y(n): Using DFT ')

(Linear convolution of x(n) & h(n) Using In built formula:

3. 1. -21. 40. -28. 3. 2.

Linear convolution of x(n) & h(n) is y(n): Using DFT

3. 1. -21. 40. -28. 3. 2.


Experiment – 7
Aim: Verification of Linearity property, circular time shift property & circular frequency shift
property of DFT.

Proof :

a) Linearity property

The linearity property of the discrete Fourier transform (DFT) states that:
For any two sequences x and y, and any two scalars a and b, the DFT of the sequence (ax
+ by) is equal to (aX) + (bY), where X and Y are the DFTs of x and y, respectively.
Mathematically, it can be expressed as:
DFT(ax + by) = aDFT(x) + bDFT(y)
This property makes the DFT a useful tool for analyzing and processing linear systems.

b) Circular Time Shift Property

The circular time shift property of the discrete Fourier transform (DFT) states that:
For any sequence x of length N, and an integer k such that 0 <= k < N, the DFT of the
circularly shifted sequence x_shift, where x_shift[n] = x[(n-k) mod N], is equal to the
element-wise multiplication of the DFT of x by a complex exponential sequence.
Mathematically, it can be expressed as:
DFT(x_shift) = DFT(x) * exp(-j * 2 * π * k * n / N)
where j is the imaginary unit, π is the mathematical constant pi, and * represents element-
wise multiplication.
This property makes the DFT a useful tool for analyzing and processing signals that have
undergone circular time shifts.
c) Circular frequency shift property

The circular frequency shift property of the discrete Fourier transform (DFT) states that:

For any sequence x of length N, and an integer k such that 0 <= k < N, the inverse DFT (IDFT) of
the element-wise multiplication of the DFT of x by a complex exponential sequence, is equal to
the circularly shifted sequence x_shift, where x_shift[n] = x[(n+k) mod N].

Mathematically, it can be expressed as:

IDFT(DFT(x) * exp(j * 2 * π * k * n / N)) = x_shift

where j is the imaginary unit, π is the mathematical constant pi, and * represents element-wise
multiplication.

This property makes the DFT a useful tool for analyzing and processing signals that have
undergone circular frequency shifts.

Properties of DFT:

i) Linearity:
dft(ax(n)+by(n))=a dft(x(n))+b dft(y(n))

clc
close all
N = 4;
x =[1 4 5 7]
g = [3 6 4 2]
a=2;
b=3;
LHS= fft(a*x+b*g)
RHS= a*fft(x)+b*fft(g)

Result: x = 1 4 5 7

g= 3 6 4 2

LHS = 79.0000 + 0.0000i -11.0000 - 6.0000i -13.0000 + 0.0000i -11.0000 + 6.0000i

RHS = 79.0000 + 0.0000i -11.0000 - 6.0000i -13.0000 + 0.0000i -11.0000 + 6.0000i


Circular Time Shift Property

// Circular Time Shift Property


clc;
x = [1, 2, 3, 4, 5];
// Apply a circular time shift to the signal
y = circshift(x, 2);
// Verify the circular time shift property
N = length(x);
X = fft(x);
Y = fft(y);
for k=0:N-1
phase = exp(-%i*2*%pi*k*2/N);
disp( X(k+1)*phase ,Y(k+1), );
end

Output:
15. + 0.i
15.
4.045085 - 1.3143278i
4.045085 - 1.3143278i
-1.545085 - 2.126627i
-1.545085 - 2.126627i
-1.545085 + 2.126627i
-1.545085 + 2.126627i

Circular Frequency Shift Property

// Circular Frequency Shift Property


clc
x = [1, 2, 3, 4, 5];
y = (abs(fft(x)));
shift=3;
d1=[0 0 0 0 0]
N = length(x);
for k=0:N-1
phase = exp(-%i*2*%pi*k*shift/N);
d1(k+1)= x(k+1).*phase
end
disp('lhs',abs(fft(d1)))
disp('rhs',y)

Output:

"lhs"

2.6286556 4.253254 15. 4.253254 2.6286556

"rhs"
15. 4.253254 2.6286556 2.6286556 4.253254

Experiment –8

Aim: Develop decimation in time radix-2 FFT algorithm without using built-in functions

Theory: In DIT radix -2 FFT the time domain sequence is decimated into 2-point sequences.
For each 2-point sequence,2 -point DFT can be computed. From the result of 2-point DFT the 4-
point DFT can be calculated. From the result of 4-point DFT the 8- point DFT can be calculated.

//Code for Radix two FFT


clc;
clear ;
clf;

X=[2 1 1 2]; // Input sequence


N=length(X);
A=2 ; // no of levels
x=zeros(1,4); // appending zeros
c=[0 2 1 3]

x(1)= X(1);
x(2)= X(3);
x(3)= X(2);
x(4)= X(4);

//disp(x)
j=sqrt(-1);
N=4; // N-Point DFT
w = cos(2*%pi/N*[0:(N/2-1)])-j*sin(2*%pi/N*[0:(N/2-1)]);
//disp(w)

Y1=zeros(1,2);
Y1(1)=x(1)+x(2)
Y1(2)=x(1)-x(2)

Y2=zeros(1,2);
Y2(1)=x(3)+x(4)
Y2(2)=x(3)-x(4)

//disp(Y1)
//disp(Y2)

Z=zeros(1,4);
Z(1)=Y1(1)+Y2(1)
Z(2)=Y1(2)+Y2(2).*w(2)
Z(3)=Y1(1)-Y2(1)
Z(4)=Y1(2)-Y2(2).*w(2)

disp(Z,'Radix 2 FFT without using inbuilt function')


// DFT using in built function

p=fft(X);
disp(p,'FFT using inbuilt function')

Output:

Radix 2 FFT without using inbuilt function

6. 1. + i 0. 1. - i

FFT using inbuilt function

6. 1. + i 0. 1. - i
Experiment 9

Aim: Design and implementation of digital low/High pass FIR filter using a window to meet the
given specifications

Theory:

// To Design a Low Pass FIR Filter


clc ;
clear ;
close ;
wp=input('Enter the pass band edge frequency(radians)=');
ws=input('Enter the stop band edge frquency (radians)=');
ks=input('Enter the stop band attenuation(db)=');

// If 43<Ks<54 choose hamming window


//To select N order of filter .
N=(2*%pi*4)./(ws-wp); //k=4 for Hamming window.
N=ceil(N);//To round−off N to the next integer .
wc=(wp +(ws-wp )/2)./%pi
// To obtain FIR filter Impulse Response ’wft ’
//And FIR Filter response ’wfm ’
[wft,wfm,fr]= wfir('lp',N +1,[wc/2,0],'hm',[0,0]);
figure(1)
a=gca();
a.x_location="origin";
a.y_location="origin";
a.data_bounds = [0,-150;1,50];
plot(2*fr ,20*log10( wfm ),'r')
xlabel('Normalized Digital Frequency w−−>')
ylabel('Frquency Response in DB H( jw )=')
title('Frequency Response for FIR Filter')
xgrid (1)

Output:

Enter the pass band edge frequency(radians)=0.3*%pi

Enter the stop band edge frquency (radians)=0.45*%pi

Enter the stop band attenuation(db)=50


// To Design a High Pass FIR Filter
clc ;
clear ;
close ;
wp=input('Enter the pass band edge frequency(radians)=');
ws=input('Enter the stop band edge frquency (radians)=');
ks=input('Enter the stop band attenuation(db)=');

// If 43<Ks<54 choose hamming window


//To select N order of filter .
N=(2*%pi*4)./(ws-wp); //k=4 for Hamming window.
N=ceil(N);//To round−off N to the next integer .
wc=(wp +(ws-wp )/2)./%pi
// To obtain FIR filter Impulse Response ’wft ’
//And FIR Filter response ’wfm ’
[wft,wfm,fr]= wfir('hp',N +1,[wc/2,0],'hm',[0,0]);
figure(1)
a=gca();
a.x_location="origin";
a.y_location="origin";
a.data_bounds = [0,-150;1,50];
plot(2*fr ,20*log10( wfm ),'r')
xlabel('Normalized Digital Frequency w−−>')
ylabel('Frquency Response in DB H( jw )=')
title('Frequency Response for FIR Filter')
xgrid (1)

Output:

Enter the pass band edge frequency(radians)=0.3*%pi

Enter the stop band edge frquency (radians)=0.45*%pi

Enter the stop band attenuation(db)=50


Experiment 10

Aim: Design and implementation of digital low/High pass IIR filter using a window to meet the
given specifications

Theory:

//Design and implementation of digital IIR Butterworth low pass filter to meet the given
specifications.
//Frequency Response
clc ;
clear ;
close ;
fp=1000 // pass band edge frequency(HZ);
fs=1500 // Enter the stop band edge (Hz)
kp=-1 // pass band attenuation(db);
ks=-3 //Stop band attenuation(db) ;
Fs=8000 //sampling rate sample/sec;

d1=10^(kp/20);
d2 =10^(ks/20);
d=sqrt((1/(d2^2))-1);
E=sqrt((1/(d1^2))-1);
// Digital Filter specifications(rad/samples)
wp =2*%pi*fp*1/Fs ;
ws =2*%pi*fs*1/Fs ;
disp(wp,'Digital Pass band edge freq in rad/samples wp=')
disp(ws,'Digital Stop band freq in rad/samples ws=')
// Pre warping
op=2*Fs*tan(wp/2);
os =2*Fs*tan(ws/2);
disp(op,'Analog Pass Band Edge Freq in rad/sec op=')
disp(os,'Analog Stop band Edge Freq in rad/sec os=')

N = log10(d/E)/log10(os/op);
oc = op/((E^2)^(1/(2* N)));
N = ceil(N); // rounded to nearest integer
disp(N,'IIR Filter order N =');
disp(oc ,'cutof frequency in rad/seconds OC =')
[pols,gn] = zpbutt(N,oc) ;
disp(gn ,'Gain of analog filter =')
disp(pols,'poles of analog IIR butterworth LPF poles=')

HS=poly(gn,'s','coeff')/real(poly(pols ,'s')) ;
disp(HS,'Transfer function of Analog IIR BButterworth LPF H(S)=')
z = poly(0,'z')
Hz=horner(HS,(2*Fs*(z-1)/(z+1)))
num = coeff(Hz(2))
den = coeff(Hz(3))
Hz(2)=Hz(2)./den(3);
Hz(3)=Hz(3)./den(3);
disp(Hz,'Transfer function of Digital IIR Butterworth LPF H(z)')

[Hw,w] = frmag(Hz,256) ;
figure(1)
plot(2*w*%pi,20*log10(abs(Hw))) ;
xlabel('Digital Frequency w−−−>')
ylabel('Magnitude in dB 20log |H(w)|=')
title('Magnitude Response of IIR LPF')
xgrid(1)

Output:

Enter the pass band edge frequency(HZ)=1500


Enter the stop band edge (Hz)=2000
Enter the pass band attenuation(db)=-1
Enter the stop band attenuation(db)=-3
Enter the sampling rate sample/sec=8000
Digital Pass band edge freq in rad/samples wp= 1.1780972
Digital Stop band freq in rad/samples ws= 1.5707963

Analog Pass Band Edge Freq in rad/sec op= 10690.858

Analog Stop band Edge Freq in rad/sec os= 16000.

IIR Filter order N = 2.

cutof frequency in rad/seconds OC = 16022.769

Gain of analog filter = 2.567D+08

poles of analog IIR butterworth LPF poles= -11329.809 + 11329.809i -11329.809 - 11329.809i

Transfer function of Analog IIR BButterworth LPF H(S)=

2.567D+08
---------------------------
2.567D+08 + 22659.618s + s2

Transfer function of Digital IIR Butterworth LPF H(z)

0.2933099 + 0.5866197z2 + 0.2933099z


------------------------------------ ---------------
0.1715734 + 0.0016661z2 + z

//Design and implementation of digital IIR Butterworth high pass filter to meet the given
specifications.
//Frequency Response
clc ;
clear ;
close ;
fp=1000 // pass band edge frequency(HZ);
fs=1500 // Enter the stop band edge (Hz)
kp=-1 // pass band attenuation(db);
ks=-3 //Stop band attenuation(db) ;
Fs=8000 //sampling rate sample/sec;

d1=10^(kp/20);
d2 =10^(ks/20);
d=sqrt((1/(d2^2))-1);
E=sqrt((1/(d1^2))-1);
// Digital Filter specifications(rad/samples)
wp =2*%pi*fp*1/Fs ;
ws =2*%pi*fs*1/Fs ;
disp(wp,'Digital Pass band edge freq in rad/samples wp=')
disp(ws,'Digital Stop band freq in rad/samples ws=')
// Pre warping
op=2*Fs*tan(wp/2);
os =2*Fs*tan(ws/2);
disp(op,'Analog Pass Band Edge Freq in rad/sec op=')
disp(os,'Analog Stop band Edge Freq in rad/sec os=')

N = log10(d/E)/log10(os/op);
oc = op/((E^2)^(1/(2* N)));
N = ceil(N); // rounded to nearest integer
disp(N,'IIR Filter order N =');
disp(oc ,'cutof frequency in rad/seconds OC =')
[pols,gn] = zpbutt(N,oc) ;
disp(gn ,'Gain of analog filter =')

disp(pols,'poles of analog IIR butterworth LPF poles=')


HS=poly(gn,'s','coeff')/real(poly(pols ,'s')) ;
disp(HS,'Transfer function of Analog IIR BButterworth LPF H(S)=')

z = poly(0,'z')
Hz=horner(HS,(2*Fs*(z-1)/(z+1)))
num = coeff(Hz(2))
den = coeff(Hz(3))
Hz(2)=Hz(2)./den(3);
Hz(3)=Hz(3)./den(3);
disp(Hz,'Transfer function of Digital IIR Butterworth LPF H(z)')
[Hw,w] = frmag(1-Hz,256) ;
figure(1)
plot(2*w*%pi,20*log10(abs(Hw))) ;
xlabel('Digital Frequency w−−−>')
ylabel('Magnitude in dB 20log |H(w)|=')
title('Magnitude Response of IIR LPF')
xgrid(1)

Output

Digital Pass band edge freq in rad/samples wp= 0.7853982

Digital Stop band freq in rad/samples ws= 1.1780972

Analog Pass Band Edge Freq in rad/sec op= 6627.417

Analog Stop band Edge Freq in rad/sec os= 10690.858

IIR Filter order N = 2.

cutof frequency in rad/seconds OC = 10708.904

Gain of analog filter = 1.147D+08

poles of analog IIR butterworth LPF poles= -7572.3383 + 7572.3383i -7572.3383 - 7572.3383i

Transfer function of Analog IIR BButterworth LPF H(S)=

1.147D+08
---------------------------
1.147D+08 + 15144.677s + s2

Transfer function of Digital IIR Butterworth LPF H(z)

0.1870823 + 0.3741647z + 0.1870823z2


------------------------------------

0.2094074 - 0.4610781z + z2
Digital Signal Processing LAB VIVA Questions

1) Mention basic blocks of DSP and DSP Applications


2) Mention advantages and disadvantages of DSP
3) Discuss the effect of undersampling for the given signal
4) Discuss the effect of Nyquist sampling for the given signal
5) Discuss the effect of oversampling for the given signal.
6) Define Linear Convolution
7) Define Circular convolution
8) Explain how Circular convolution is performed using Linear Convolution
9) Define Autocorrelation of Signal
10) Define Cross-correlation of two signal
11) Explain properties of Correlation.
12) Obtain the circular convolution of the following sequences x(n) = {1,2,1}; h(n) = {1, -2,2}
13) Define DFT and IDFT
14) How many multiplications and additions are required to compute N –point DFT using
radix – 2 FFT?
15) Distinguish between DFT and DTFT?
16) What is zero padding? What are its uses?
17) What is twiddle factor?

18) What is meant by in – place computation?


19) What are the differences and similarities between DIT and DIF.
20) Distinguish between linear convolution and circular convolution?
21) What are the differences between Overlap – add and Overlap – save method?
22) State the properties of DFT?
23) How will you perform linear convolution using circular convolution?
24) Find the circular convolution of x(n) = {1,2,3,4} with h(n) = {1,1,2,2}?
25) State Parseval’s relation with respect to DFT?
26) Explain Radix – 2 DIF FFT algorithm. Compare it with DIT – FFT algorithms.

27) Compute the linear convolution of finite duration sequences h(n) = {1,2} and x(n) = {1,
2, -1, 2, 3, -2, -3, -1, 1, 1, 2, -1} by Overlap add method?
28) Perform the linear convolution of the sequence x(n) = {1, -1, 1, -1} and h(n) = {1,2,3,4} using
DFT method
29) Compare Butterworth with Chebyshev filters?
30) What is known as pre warping in digital filters?
31) List the properties of Chebyshev filter?
32) Draw the direct form structure of IIR filter?
33) Why do we go for analog approximation to design a digital filter?
34) What is the advantage of direct form II realization when compared to direct form I
realization?
35) Why the Butterworth response is called a maximally flat response?
36) . Mention the advantages of cascade realization?
37) Write the properties of Butterworth filter?
38) What is bilinear transformation?
39) What are the advantages and disadvantages of bilinear transformation?
40) Distinguish between recursive realization and non recursive realization?
41) What is meant by impulse invariance method of designing IIR filter?
42) Give the expression for location of poles of normalized Butterworth filter?
43) What are the parameters that can be obtained from Chebyshev filter specification?
44) Explain the procedure for designing analog filters using the Chebyshev approximation.
45) What are advantages and disadvantages of FIR filter?
46) What is the reason that FIR filter is always stable?
47) State the condition for a digital filter to be causal and stable?
48) Compare Hamming window with Kaiser window.
49) What is the principle of designing FIR filter using frequency sampling method?
50) What is window and why it is necessary?

You might also like