Digital Signal Processing Lab Manual MS
Digital Signal Processing Lab Manual MS
LABORATORY RECORD
Name......................................................
r.B
Roll Number.................................................
D
Branch..........................................................
University Reg. No...........................................
1
Contents
2
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-1
Experiment No:-1 Date:———————–
1. AIM : To familiarize matlab tool box basic funtion
2. OBJECTIVES:
(a) To study the basic matlab tool box function from the
command promt.
MATLAB
• MATLAB is a software package for high performance
numerical computation and visualization provides an in-
teractive environment with hundreds of built in func-
tions for technical computation, graphics and anima-
.
.G
tion.
.V
r.B
3
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
4
Dr. Biju V.G. Digital Signal Processing Lab Manual
• Key Features:
– High-level language for technical computing.
– Development environment for managing code, files,
and data.
– Interactive tools for iterative exploration, design, and
problem solving.
– Mathematical functions for linear algebra, statistics,
Fourier analysis,
– Filtering, optimization, and numerical integration.
– 2-D and 3-D graphics functions for visualizing data.
– Tools for building custom graphical user interfaces.
– Functions for integrating MATLAB based algorithms
with external applications and languages, such as C,
.
.G
basic windows
– Command Window:- This is the main window .It is
characterized by MATLAB command prompt(>>) when
you launch the application program MATLAB puts
you in this window all commands including those
for userwritten programs ,are typed in this window
at the MATLAB prompt.
5
Dr. Biju V.G. Digital Signal Processing Lab Manual
6
Dr. Biju V.G. Digital Signal Processing Lab Manual
1. T = 0:1:10
3. T= zeros (2, 3)
r.B
D
T=
000
000
7
Dr. Biju V.G. Digital Signal Processing Lab Manual
4. T=ones (3,2)
The above instruction creates a vector of three rows and
two columns whose values are one.
T=
11
11
11
5. a = [1 2 3] b = [4 5 6]
tion.
7. plot(t,m):-
8
Dr. Biju V.G. Digital Signal Processing Lab Manual
9. subplot():-
14. clc :-
9
Dr. Biju V.G. Digital Signal Processing Lab Manual
15. clear:-
19. pwd :-
D
10
Dr. Biju V.G. Digital Signal Processing Lab Manual
21. ceil() :-
Size of array.
D
11
Dr. Biju V.G. Digital Signal Processing Lab Manual
25. length() :-
Length of vector.
length(X) returns the length of vector X.
It is equivalent to MAX(SIZE(X)) for non-empty arrays
and 0 for empty ones.
26. abs():-
Absolute value.
abs(X) is the absolute value of the elements of X.
When X is complex, abs(X) is the complex modulus (mag-
nitude) of the elements of X.
27. angle ():-
Phase angle.
.
28. disp():-
D
Display array.
disp(X) displays the array, without printing the array name.
29. min():-
Smallest component.
For vectors, min(X) is the smallest element in X.
For matrices, min(X) is a row vector containing the min-
imum element from each column.
12
Dr. Biju V.G. Digital Signal Processing Lab Manual
30. max():-
Largest component.
For vectors, max(X) is the largest element in X.
For matrices, max(X) is a row vector containing the max-
imum element from each column.
31. mod ():-
Exponential.
exp(X) is the exponential of the elements of X, e to the
X.
33. input():-
.
.G
13
Dr. Biju V.G. Digital Signal Processing Lab Manual
34. printsys():-
14
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-1
Experiment No:-2 Date:———————–
1. AIM : To familiarize DSP tool box basic funtion
2. OBJECTIVES:
(a) To study the DSP tool box function from the com-
mand promt.
Basic Instructions & functions in Matlab
• conv():-
• cconv():-
.V
r.B
15
Dr. Biju V.G. Digital Signal Processing Lab Manual
• freqz():-
For example,
D
Lowpass: Wp = .1, Ws = .2
Highpass: Wp = .2, Ws = .1
Bandpass: Wp = [.2 .7], Ws = [.1 .8]
Bandstop: Wp = [.1 .8], Ws = [.2 .7]
buttord also returns Wn, the Butterworth natural fre-
quency (or, the ”3 dB frequency”) to use with BUTTER
to achieve the specifications.
16
Dr. Biju V.G. Digital Signal Processing Lab Manual
• butter():-
If Wn is a two-element vector,
Wn = [W1 W2], butter returns an order 2N bandpass filter
with passband W 1 < W < W 2.
[B, A] = butter(N,Wn,’high’) designs a highpass filter.
[B, A] = butter(N,Wn,’low’) designs a lowpass filter.
.
.G
.V
W n = [W 1 W 2].
D
• fir1():-
17
Dr. Biju V.G. Digital Signal Processing Lab Manual
18
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
19
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-1
Experiment No:-3 Date:———————–
1. AIM : To perform Matrix Multiplication/Subtraction/Addition/Divis
2. OBJECTIVES:
(a) To perform Matrix Multiplication/Subtraction/Addition/Division
using user defined function.
Matlab program to perform Matrix
Multiplication/Subtraction/Addition/Division
• clc;
• close all;
• clear all;
.
.G
.V
20
Dr. Biju V.G. Digital Signal Processing Lab Manual
• disp(E)
• disp(’The Matrix element vice multiplication output is’)
• disp(F)
• disp(’The Matrix division output is’)
• disp(G)
• disp(’The Matrix element vice division output is’)
• disp(H)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Function to perform Arithmetic operations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
• function [C D E F G H]=compute(A,B)
• disp(’Inside function’)
.
.G
• C=A+B;
.V
r.B
• D=A-B;
D
• E=A*B;
• A.*B;
• G=B/A;
• H=A./B;
• disp(’Leaving function’)
• end
21
Dr. Biju V.G. Digital Signal Processing Lab Manual
Input
22
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
23
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-1
Experiment No:-4 Date:———————–
1. AIM : To generate basic signals like unit impulse, unit
step, unit ramp signal and Exponential signals.
2. OBJECTIVES:
(a) To generate basic signals like unit impulse, unit step,
unit ramp signal and Exponential signals using Mat-
lab.
• clc;
.
.G
• close all;
.V
r.B
• clear all;
D
24
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(3,4,2)
• stem(c,a)
• title(’ Discrete Unit Impulse function’)
• xlabel(’Time axis’)
• ylabel(’Impluse Amplitude’)
• subplot(3,4,3)
• plot(c,b)
• title(’Unit step function’)
• xlabel(’Time axis’)
• ylabel(’Step Amplitude’)
• subplot(3,4,4)
• stem(c,b)
.
.G
• xlabel(’Time axis’)
D
• ylabel(’Step Amplitude’)
• x=0:0.2:2*pi;
• y=sin(x)
• subplot(3,4,5)
• plot(x,y)
• title(’Sine wave’)
• xlabel(’Time axis’)
• ylabel(’Sine Amplitude’)
25
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(3,4,6)
• stem(x,y)
• title(’ Discrete Sine wave’)
• xlabel(’Time axis’)
• ylabel(’Sine Amplitude’)
• x=0:5;
• subplot(3,4,7)
• plot(x,x)
• title(’Triangular wave’)
• xlabel(’Time axis’)
• ylabel(’Triangular Amplitude’)
• subplot(3,4,8)
.
.G
• stem(x,x)
.V
r.B
• xlabel(’Time axis’)
• ylabel(’Triangular Amplitude’)
• x=0:5;
• y=0.5
• z = yx
• subplot(3,4,9)
• plot(x, z)
• title(’Exponential wave’)
• xlabel(’Time axis’)
• ylabel(’Exponential Amplitude’)
26
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(3,4,10)
• stem(x,z)
• title(’ Discrete Exponential wave’)
• xlabel(’Time axis’)
• ylabel(’Exponential Amplitude’)
• x=-10:10;
• y=[ones(1, 5) −1.∗ones(1, 5) ones(1, 6) −1.∗ones(1, 5)]
• subplot(3,4,11)
• plot(x,y)
• title(’Square wave’)
• xlabel(’Time axis’)
• ylabel(’Square wave Amplitude’)
.
.G
• subplot(3,4,12)
.V
r.B
• stem(x,y)
D
27
Dr. Biju V.G. Digital Signal Processing Lab Manual
Sample Ouputs
.
.G
.V
r.B
D
28
Dr. Biju V.G. Digital Signal Processing Lab Manual
Ouput Diagram
.
.G
.V
r.B
D
29
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
30
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-2
Experiment No:-5 Date:———————–
1. AIM : Matlab program to compute Linear Convolution of
two signals
2. OBJECTIVES:
(a) Matlab program to compute Linear Convolution of
two discrete time signals and verify the result using
DSP tool box function conv().
• clc;
.
.G
• close all;
.V
r.B
• clear all;
D
31
Dr. Biju V.G. Digital Signal Processing Lab Manual
• f or n = 1 : n1
• sum(n)=0;
• f or k = 1 : x1
• m = n + 1 − k;
• if m <= h1
• if k < n + 1
• sum(n) = sum(n) + (x(k) ∗ h(m));
• end
• end
• end
• y(n)=sum(n);
• end
.
.G
• disp(y)
D
• subplot(4,1,1);
• stem(x);
• title(’1st sequence x’);
• xlabel(’n’);
• ylabel(’x(n)’);
32
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(4,1,2);
• stem(h);
• title(’2nd sequence h’);
• xlabel(’n’);
• ylabel(’h(n)’);
• subplot(4,1,3);
• stem(y);
• title(’Convolved sequence y’);
• xlabel(’n’);
• ylabel(’y(n)’);
• z=conv(x,h)
• subplot(4,1,4);
.
.G
• stem(z);
.V
r.B
• xlabel(’n’);
• ylabel(’y(n)’);
33
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
Input
34
Dr. Biju V.G. Digital Signal Processing Lab Manual
Output Diagram
.
.G
.V
r.B
D
35
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
36
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-2
Experiment No:-6 Date:———————–
1. AIM : Matlab program to compute circular Convolution
of two signals
2. OBJECTIVES:
(a) Matlab program to compute Circular Convolution of
two discrete time signals and verify the result using
DSP tool box function cconv().
• clc;
.
.G
• close all;
.V
r.B
• clear all;
D
37
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(4,1,2);
.V
r.B
• stem(h);
D
38
Dr. Biju V.G. Digital Signal Processing Lab Manual
• z=cconv(x,h,N)
• subplot(4,1,4);
• stem(z);
• title(’Tool box Circular Convolved output’);
• xlabel(’n’);
• ylabel(’y(n)’);
Sample Output Diagram
.
.G
.V
r.B
D
39
Dr. Biju V.G. Digital Signal Processing Lab Manual
Input
.
.G
.V
r.B
D
40
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
41
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-2
Experiment No:-7 Date:———————–
1. AIM : Matlab program to compute Linear Convolution
Using Circular Convolution.
2. OBJECTIVES:
(a) Matlab program to compute Linear Convolution of
two discrete time signals using Circular Convolution
and verify the result using DSP tool box function
conv().
• clc;
D
• close all;
• clear all;
• x=input(’Enter the 1st sequence x:’);
• h=input(’Enter the 2nd sequence h:’);
• N1=length(x);
• N2=length(h);
• N=N1+N2-1 To find linear convolution output length
• x = [x zeros(1, N 2 − 1)] ; append N-N1 zeros to x
• h = [h zeros(1, N 1 − 1)]; append N-N1 zeros to x
42
Dr. Biju V.G. Digital Signal Processing Lab Manual
• [y] =CConvolution(x,h,N);
• disp(y) % Program for plotting the output
• subplot(4,1,1);
• stem(x);
• title(’1st sequence x’);
• xlabel(’n’);
• ylabel(’x(n)’);
• subplot(4,1,2);
• stem(h);
• title(’2nd sequence h’);
• xlabel(’n’);
• ylabel(’h(n)’);
.
.G
• subplot(4,1,3);
.V
r.B
• stem(y);
D
43
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(4,1,4);
• stem(z);
• title(’Tool box Circular Convolved output’);
• xlabel(’n’);
• ylabel(’y(n)’);
Function to perform Circular Convolution
• %%%%%%%%%%% Function %%%%%%%%%%%
• function [y]=CConvolution(x,h,N)
• f or n = 0 : N − 1
• y(n + 1) = 0;
• f or i = 0 : N − 1
• j = mod(n − i, N );
.
.G
• end
D
• end
• end
44
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
Input
45
Dr. Biju V.G. Digital Signal Processing Lab Manual
Output Diagram
.
.G
.V
r.B
D
46
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
47
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-3
Experiment No:-8 Date:———————–
1. AIM : Matlab program to compute DFT.
2. OBJECTIVES:
(a) Matlab program to compute DFT of a discrete time
signals and verify the result using DSP tool box func-
tion fft().
• clc;
• close all;
.
.G
• clear all;
.V
r.B
48
Dr. Biju V.G. Digital Signal Processing Lab Manual
• if N < N 1
• disp(’Error’)
• disp(’Sequence length greater than N’)
• else
• for k=0:N-1
• f or n = 0 : N − 1
• y(k + 1) = y(k + 1) + (x(n + 1) ∗ exp(−(i) ∗ 2 ∗ pi ∗
k ∗ n/N ));
• end
• end
• disp(y)
• subplot(3,1,1);
.
.G
• stem(x);
.V
r.B
• title(’sequence x’);
D
• xlabel(’n’);
• ylabel(’x(n)’);
• subplot(3,1,2);
• stem(y);
• title(’ dft’);
• xlabel(’n’);
• ylabel(’X(K)’);
49
Dr. Biju V.G. Digital Signal Processing Lab Manual
• z=fft(x,N)
• subplot(3,1,3);
• stem(z);
• title(’Tool box FFT output’);
• xlabel(’n’);
• ylabel(’Z(K)’);
• end
Sample Output Diagram
.
.G
.V
r.B
D
50
Dr. Biju V.G. Digital Signal Processing Lab Manual
Input
.
.G
.V
r.B
D
51
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
52
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-3
Experiment No:-9 Date:———————–
1. AIM : Matlab program to compute IDFT.
2. OBJECTIVES:
(a) Matlab program to compute IDFT of a discrete time
signals and verify the result using DSP tool box func-
tion ifft().
• clc;
.
.G
• close all;
.V
r.B
• clear all;
D
53
Dr. Biju V.G. Digital Signal Processing Lab Manual
• if N < N 1
• disp(’Error’)
• disp(’Sequence length greater than N’)
• else
• for k=0:N-1
• f or n = 0 : N − 1
• y(k + 1) = y(k + 1) + (x(n + 1) ∗ exp((i) ∗ 2 ∗ pi ∗
k ∗ n/N ));
• end
• y(k+1)=y(k+1)./N;
• end
• disp(y)
.
.G
• subplot(3,1,1);
.V
r.B
• stem(x);
D
• title(’sequence x’);
• xlabel(’n’);
• ylabel(’x(n)’);
• subplot(3,1,2);
• stem(abs(y));
• title(’ idft’);
• xlabel(’n’);
• ylabel(’x(n)’);
54
Dr. Biju V.G. Digital Signal Processing Lab Manual
• z=ifft(x,N)
• subplot(3,1,3);
• stem(z);
• title(’Tool box IFFT output’);
• xlabel(’n’);
• ylabel(’z(n)’);
• end
Sample Output Diagram
.
.G
.V
r.B
D
55
Dr. Biju V.G. Digital Signal Processing Lab Manual
Input
.
.G
.V
r.B
D
56
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
57
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-3
Experiment No:-10 Date:———————–
1. AIM : Matlab program to compute convolution using DFT.
2. OBJECTIVES:
(a) Matlab program to compute Matlab program to com-
pute convolution using DFT and verify the result us-
ing DSP tool box function cconv().
• clc;
• close all;
.
.G
• clear all;
.V
r.B
58
Dr. Biju V.G. Digital Signal Processing Lab Manual
• x2=DFT(h,N);
• y1=x1.*x2;
• y=IDFT(y1,N);
• y=abs(y)
• y=y(1:N);
• z=conv(x,h)
• subplot(3,2,1);
• stem(x);
• title(’1st sequence x’);
• xlabel(’n’);
• ylabel(’x(n)’);
• subplot(3,2,2);
.
.G
• stem(x1);
.V
r.B
• title(’ X(K)’);
D
• xlabel(’n’);
• ylabel(’X(K)’);
• subplot(3,2,3);
• stem(h);
• title(’2nd sequence h’);
• xlabel(’n’);
• ylabel(’h(n)’);
59
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(3,2,4);
• stem(x2);
• title(’ H(K)’);
• xlabel(’n’);
• ylabel(’H(K)’);
• subplot(3,2,5);
• stem(y);
• title(’ Linear Convolution output’);
• xlabel(’n’);
• ylabel(’y(n)’);
• z=conv(x,h);
• z=z(1:N);
.
.G
• subplot(3,2,6);
.V
r.B
• stem(z);
D
60
Dr. Biju V.G. Digital Signal Processing Lab Manual
%%%%%%%%%%%%%%%%%%%%%%%%%%
Function to compute DFT
%%%%%%%%%%%%%%%%%%%%%%%%%%
• function [y]= DFT(x,N)
• y=zeros(1,N);
• f or k = 0 : N − 1
• f or n = 0 : N − 1
• y(k + 1) = y(k + 1) + (x(n + 1) ∗ exp(−(i) ∗ 2 ∗
pi ∗ k ∗ n/N ))
• end
• end
• end
.
.G
%%%%%%%%%%%%%%%%%%%%%%%%%%
.V
r.B
%%%%%%%%%%%%%%%%%%%%%%%%%%
• function [y]= IDFT(x,N)
• y=zeros(1,N);
• f or k = 0 : N − 1
• f or n = 0 : N − 1
• y(k + 1) = y(k + 1) + (x(n + 1) ∗ exp((i) ∗ 2 ∗ pi ∗
k ∗ n/N ));
• end
• y(k + 1) = y(k + 1)./N ;
• end
• end
61
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
Input
62
Dr. Biju V.G. Digital Signal Processing Lab Manual
Output Diagram
.
.G
.V
r.B
D
63
Dr. Biju V.G. Digital Signal Processing Lab Manual
Result:-
64
Dr. Biju V.G. Digital Signal Processing Lab Manual
CYCLE:-4
Experiment No:-11 Date:———————–
1. AIM: AIM: Design and implementation of IIR filter to meet
given specifications.
2. OBJECTIVES:
(a) To design the BUTTERWORTH filter to meet the given
specification using the MATLAB functions BUTTORD
and BUTTER.
(b) Bilinear transformation for analog-to-digital filter con-
version using function BILINEAR.
(c) To verify the result by theoretical calculations.
.
.G
3. Algorithm
.V
r.B
65
Dr. Biju V.G. Digital Signal Processing Lab Manual
• clc;
• clear all;
• close all;
.
.G
66
Dr. Biju V.G. Digital Signal Processing Lab Manual
• ang=angle(h);
.V
r.B
• subplot(2,1,1);
D
• plot(w/pi,m)
• title(’Magnitude response of Analog Low Pass Filter’)
• xlabel(’Normalized frequency’);
• ylabel(’Magnitude’);
• grid;
67
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(2,1,2);
• plot(w/pi, ang);
• title(’Phase response of Analog Low Pass Filter’)
• xlabel(’Normalized frequency’);
• ylabel(’Phase’);
• grid;
• [b, a] = bilinear(num, den,1);
• printsys(b,a,’z’);
Inputs
Enter the Pass band frequency in Hz = ————————–
Enter the Stop band frequency in Hz = ————————–
Enter the Sampling frequency in Hz = ————————–
Enter the Pass band ripple in db:—————————
.
.G
68
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
output
Prewrapped Pass band frequency:—————————-
69
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
70
Dr. Biju V.G. Digital Signal Processing Lab Manual
• Us = 2*tan(ws/2);
.V
r.B
• disp(Up)
• disp(’Prewrapped Stop band frequency’)
• disp(Us)
• [n, wn]= buttord (Up,Us,Ap,As);
• disp(’order of the filter N =’);
• disp(n);
• disp(’Normalized cut off frequency = ’);
• disp(wn);
71
Dr. Biju V.G. Digital Signal Processing Lab Manual
• xlabel(’Normalized frequency’);
D
• ylabel(’Phase’);
• grid;
• [b, a] = bilinear(num, den,1);
• printsys(b,a,’z’);
72
Dr. Biju V.G. Digital Signal Processing Lab Manual
Inputs
Enter the Pass band frequency in Hz = ————————–
Enter the Stop band frequency in Hz = ————————–
Enter the Sampling frequency in Hz = ————————–
Enter the Pass band ripple in db:—————————
Enter the Stop band ripple in db:—————————
.
.G
.V
r.B
D
73
Dr. Biju V.G. Digital Signal Processing Lab Manual
output
Prewrapped Pass band frequency:—————————-
.
.G
.V
r.B
D
74
Dr. Biju V.G. Digital Signal Processing Lab Manual
• Us = 2*tan(ws/2);
.V
r.B
• disp(Up)
• disp(’Prewrapped Stop band frequency’)
• disp(Us)
• [n, wn]= buttord (Up,Us,Ap,As);
• disp(’order of the filter N =’);
• disp(n);
• disp(’Normalized cut off frequency = ’);
• disp(wn);
75
Dr. Biju V.G. Digital Signal Processing Lab Manual
• xlabel(’Normalized frequency’);
D
• ylabel(’Phase’);
• grid;
• [b, a] = bilinear(num, den,1);
• printsys(b,a,’z’);
76
Dr. Biju V.G. Digital Signal Processing Lab Manual
Inputs
Enter the Pass band frequency in Hz = ————————–
Enter the Stop band frequency in Hz = ————————–
Enter the Sampling frequency in Hz = ————————–
Enter the Pass band ripple in db:—————————
Enter the Stop band ripple in db:—————————
.
.G
.V
r.B
D
77
Dr. Biju V.G. Digital Signal Processing Lab Manual
output
Prewrapped Pass band frequency:—————————-
.
.G
.V
r.B
D
78
Dr. Biju V.G. Digital Signal Processing Lab Manual
• Us = 2*tan(ws/2);
.V
r.B
• disp(Up)
• disp(’Prewrapped Stop band frequency’)
• disp(Us)
• [n, wn]= buttord (Up,Us,Ap,As);
• disp(’order of the filter N =’);
• disp(n);
• disp(’Normalized cut off frequency = ’);
• disp(wn);
79
Dr. Biju V.G. Digital Signal Processing Lab Manual
• xlabel(’Normalized frequency’);
D
• ylabel(’Phase’);
• grid;
• [b, a] = bilinear(num, den,1);
• printsys(b,a,’z’);
80
Dr. Biju V.G. Digital Signal Processing Lab Manual
Inputs
Enter the Pass band frequency in Hz = ————————–
Enter the Stop band frequency in Hz = ————————–
Enter the Sampling frequency in Hz = ————————–
Enter the Pass band ripple in db:—————————
Enter the Stop band ripple in db:—————————
.
.G
.V
r.B
D
81
Dr. Biju V.G. Digital Signal Processing Lab Manual
output
Prewrapped Pass band frequency:—————————-
.
.G
.V
r.B
D
82
Dr. Biju V.G. Digital Signal Processing Lab Manual
RESULT:-
Implementation of IIR Low, High, Band Pass & Band Reject
filter for the given specifications are done, the desired fre-
quency responses are plotted and computed the transfer
functions H(Z) using Bilinear Transfer function.
83
Dr. Biju V.G. Digital Signal Processing Lab Manual
CYCLE:-4
Experiment No:-12 Date:———————–
1. AIM: Design and implementation of FIR filter to meet
given specifications (low pass filter using hamming win-
dow).
2. OBJECTIVES:
(a) To design the FIR filter by Hamming window using
the inbuilt MATLAB function FIR1 and HAMMING.
(b) To verify the result by theoretical calculations
3. Algorithm
.
.G
84
Dr. Biju V.G. Digital Signal Processing Lab Manual
• Wc = Wc1/pi;
.V
r.B
• disp(Wc);
• h = fir1(N-1,Wc, ’low’);
• disp(’Impulse Response of FIR filter=’);
• disp(h);
• figure,freqz(h);
• xlabel(’n’);
• ylabel(’h(n)’);
• title(’FIR Low Pass Filter response without using Win-
dow ’);
85
Dr. Biju V.G. Digital Signal Processing Lab Manual
• wn = (hamming(N));
• h1=h.*wn’;
• figure,freqz(h1);
• xlabel(’n’);
• ylabel(’h(n)’);
• title(’FIR Low Pass Filter response using hamming Win-
dow’);
Inputs
enter the Pass band edge in radians =————–
86
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
87
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
88
Dr. Biju V.G. Digital Signal Processing Lab Manual
• Wc = Wc1/pi;
.V
r.B
• disp(Wc);
• h = fir1(N-1,Wc, ’high’);
• disp(’Impulse Response of FIR filter=’);
• disp(h);
• figure,freqz(h);
• xlabel(’n’);
• ylabel(’h(n)’);
• title(’FIR Low Pass Filter response without using Win-
dow ’);
89
Dr. Biju V.G. Digital Signal Processing Lab Manual
• wn = (hamming(N));
• h1=h.*wn’;
• figure,freqz(h1);
• xlabel(’n’);
• ylabel(’h(n)’);
• title(’FIR Low Pass Filter response using hamming Win-
dow’);
Inputs
enter the Pass band edge in radians =————————–
90
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
91
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
92
Dr. Biju V.G. Digital Signal Processing Lab Manual
RESULT:-
Implementation of FIR filter for the given specifications is
done and the desired frequency response is obtained for
low and high pass FIR filter, with and without using window.
93
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-4
Experiment No:-13 Date:———————–
1. AIM : Matlab program to compute block convolution us-
ing overlap save method .
2. OBJECTIVES:
(a) Matlab program to compute block convolution using
overlap save method and verify the result using DSP
tool box function conv().
Matlab program to compute block convolution using
overlap save method
• clc;
.
.G
• close all;
.V
r.B
• clear all;
D
94
Dr. Biju V.G. Digital Signal Processing Lab Manual
• if (N < M )
• disp(’ Block size L must greater than the length of im-
pulse response ’)
• break
• end
• M1=M-1;
• DL=N-M+1;
• x = [zeros(1, M-1), x , zeros(1,N-1)];
• h = [h, zeros(1,N-M)];
• L=floor((Ls+M1-1)/DL);
• Y=zeros(L+1,N);
• for k=0:L
.
.G
• xk=x(k*DL+1:k*DL+N);
.V
r.B
• Y (k + 1, :) = CConvolution(xk, h, N );
D
• end
• Y=Y(:,M:N);
• Y=transpose(Y);
• f=Y(:)’;
• p=conv(X,H);
• disp(’using over lap save method’)
• disp(f)
95
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(4,1,3);
.V
r.B
• stem(f);
D
96
Dr. Biju V.G. Digital Signal Processing Lab Manual
%%%%%%%%%%% %%%%%%%%%%%
Function to perform Circular Convolution
%%%%%%%%%%% %%%%%%%%%%%
• function [y]=CConvolution(x,h,N)
• f or n = 0 : N − 1
• y(n + 1) = 0;
• f or i = 0 : N − 1
• j = mod(n − i, N );
• y(n + 1) = y(n + 1) + x(i + 1) ∗ h(j + 1);
• end
• end
• end
.
.G
.V
r.B
D
97
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
Input
98
Dr. Biju V.G. Digital Signal Processing Lab Manual
Output Diagram
.
.G
.V
r.B
D
99
Dr. Biju V.G. Digital Signal Processing Lab Manual
RESULT:-
100
Dr. Biju V.G. Digital Signal Processing Lab Manual
Cycle:-4
Experiment No:-14 Date:———————–
1. AIM : Matlab program to compute block convolution us-
ing overlap add method.
2. OBJECTIVES:
(a) Matlab program to compute block convolution using
overlap add method and verify the result using DSP
tool box function conv().
Matlab program to compute block convolution using
overlap add method
• clc;
.
.G
• close all;
.V
r.B
• clear all;
D
101
Dr. Biju V.G. Digital Signal Processing Lab Manual
• if (N < M )
• disp(’ Block size L must greater than the length of im-
pulse response ’)
• break
• end
• DL=N-M+1;
• h=[h zeros(1,(N-M))];
• L=floor((Ls+M-2)/DL);
• Xnew= zeros(L,N);
• Ynew= zeros(L,N);
• x=[x zeros(1,N-1)];
• for i=0:L
.
.G
• xx = [zeros(1, M − 1)];
.V
r.B
• a = [DL ∗ i + 1 : DL ∗ i + DL];
D
• xy = x(a);
• Xnew(i + 1, :) = [xy xx];
• xd = [xy xx];
• Y new(i + 1, :) = CConvolution(xd, h, N );
• end
102
Dr. Biju V.G. Digital Signal Processing Lab Manual
• OAM=[zeros(L+1,Ls+M-1)];
• for i=0:L
• a = i ∗ DL + 1;
• OAM ((i + 1), a : a + N − 1) = Y new(i + 1, :);
• end
• disp(’user defined function’)
• OAM=sum(OAM);
• OAM=OAM(1:Ls+M-1)
• disp(’built in function’)
• P=conv(X,H)
• subplot(4,1,1);
• stem(X);
.
.G
• xlabel(’n’);
D
• ylabel(’x(n)’);
• subplot(4,1,2);
• stem(H);
• title(’ Inpulse Response(h(n)’);
• xlabel(’n’);
• ylabel(’h(n)’);
103
Dr. Biju V.G. Digital Signal Processing Lab Manual
• subplot(4,1,3);
• stem(OAM);
• title(’ Overlap add method output’);
• xlabel(’n’);
• ylabel(’y(n)’);
• subplot(4,1,4);
• stem(P);
• title(’DSP Tool box function conv output’);
• xlabel(’n’);
• ylabel(’y(n)’);
%%%%%%%%%%% %%%%%%%%%%%
.
%%%%%%%%%%% %%%%%%%%%%%
r.B
D
• function [y]=CConvolution(x,h,N)
• f or n = 0 : N − 1
• y(n + 1) = 0;
• f or i = 0 : N − 1
• j = mod(n − i, N );
• y(n + 1) = y(n + 1) + x(i + 1) ∗ h(j + 1);
• end
• end
• end
104
Dr. Biju V.G. Digital Signal Processing Lab Manual
.
.G
.V
r.B
D
Input
105
Dr. Biju V.G. Digital Signal Processing Lab Manual
Output Diagram
.
.G
.V
r.B
D
106
Dr. Biju V.G. Digital Signal Processing Lab Manual
RESULT:-
107