0% found this document useful (0 votes)
3 views58 pages

DSP Final Merged

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)
3 views58 pages

DSP Final Merged

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/ 58

ANNA UNIVERSITY REGIONAL CAMPUS MADURAI

MADURAI-625019

DEPARTMENT OF

ELECTRICAL AND ELECTRONICS ENGINEERING

LAB RECORD

EE3024 – DIGITAL SIGNAL PROCESSING SYSTEM DESIGN LABORATORY


ANNA UNIVERSITY REGIONAL CAMPUS MADURAI
MADURAI-625019

BONAFIDE CERTIFICATE

Certified that this is the Bonafide Record of work done by


Register No: of VI Semester/III Year B.E Electrical
and Electronics Engineering in the EE3024 – Digital Signal Processing System Design
Laboratory during the Academic Year 2024-2025.

Staff-In-Charge HOD

Submitted for the University Practical Examination held on at


Anna University Regional Campus, Madurai.

Internal Examiner External Examiner


CONTENTS
EXP. PAGE
DATE TITLE OF THE EXPERIMENT MARKS SIGNATURE
NO. NO.
1. GENERATION OF BASIC SIGNALS

2. LINEAR CONVOLUTION

3. CIRCULAR CONVOLUTION

4. Z – TRANSFORM

5. MAGNITUDE AND PHASE SPECTRUM OF 8


POINT DFT SEQUENCE

6. MAGNITUDE AND PHASE SPECTRUM OF 8


POINT IDFT SEQUENCE

7. SECOND ORDER HIGH PASS FILTER USING


BILINEAR TRANSFORMATION

8. SECOND ORDER LOW PASS FILTER USING


BILINEAR TRANSFORMATION

9. CHEBYSHEV THIRD ORDER LOW PASS


FILTER USING IMPULSE INVARIANT
TRANSFORMATION
10. CHEBYSHEV THIRD ORDER LOW PASS
FILTER USING BILINEAR
TRANSFORMATION
11. DETERMINE THE IMPULSE RESPONSE OF
FIR LOW PASS FILTER USING
RECTANGULAR WINDOW METHOD
12. DETERMINE THE IMPULSE RESPONSE OF
FIR HIGH PASS FILTER USING HAMMING
WINDOW METHOD
13. DETERMINE THE IMPULSE RESPONSE OF
FIR BAND PASS FILTER USING HANNING
WINDOW METHOD
14. DETERMINE THE IMPULSE RESPONSE OF
FIR BAND-STOP FILTER USING
RECTANGULAR WINDOW METHOD
EX N0: 01
DATE: GENERATION OF BASIC SIGNALS

AIM :
To write a matlab program to perform unit impulse, unit step.

PROGRAM:
Unit impulse signal :
clc;
clear all;
close all;
t=-2:1:2;
y=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(2,2,1);
stem(t,y);
xlabel('(a) n-->');
ylabel('amplitude-->');

Unit step sequence:


n=input('enter the N value');
t=0:1:n-1;
y1=ones(1,n);
subplot(2,2,2);
stem(t,y1);
xlabel('(b) n->’');
ylabel('amplitude-->');
OUTPUT:

Unit impulse signal

Unit step sequence:

Enter the N value : 5


RESULT:
Thus the matlab program for generation of basic signals was executed and verified.
EX NO:02 LINEAR CONVOLUTION
DATE:

AIM:
To write a matlab program to perform linear convolution.
PROGRAM:
clc;
close all;
clear all;
x=input('enter the 1st sequence');
h=input('enter the 2nd sequence');
y=conv(x,h);
figure;
subplot(3,1,1);
stem(x);
ylabel('Amplitud');
xlabel('(a) n-->');
subplot(3,1,2);
stem(h);
ylabel('Amplitud');
xlabel('(b) n-->');
subplot(3,1,3);
stem(y);
ylabel('Amplitude';
xlabel('(c) n-->');
disp('The resultant signal is');y
OUTPUT:

Enter the 1st sequence [1 2]


Enter the 2nd sequence [1 2 4]
The resultant signal is
y=
1 4 8 8
RESULT:
Thus the matlab program for linear convolution executed and verified
EX NO:03
CIRCULAR CONVOLUTION
DATE:

AIM:
To write a matlab program to perform circular convolution.

PROGRAM:
clc;
clear all;
N = 4;
x1 = [0,1,0,1];
x2 = [1,2,1,2];
disp('The 4-point DFT of x1(n) is,');
x1 = fft(x1,N)
disp('The 4-point DFT of x2(n) is,');
x2 = fft(x2,N)
disp('The product of DFTS is,');
x1x2 = x1.*x2
disp('circular convolution of x1(n) and x2(n) is,');
x3 = ifft(x1x2)
OUTPUT:

The 4-point DFT of x1(n) is,

x1 =

2 0 -2 0

The 4-point DFT of x2(n) is,

x2 =

6 0 -2 0

The product of DFTS is,

x1x2 =

12 0 4 0

circular convolution of x1(n) and x2(n) is,

x3 =

4 2 4 2
RESULT:

Thus the matlab program for circular convolution executed and verified.
Write the MATLAB program to find poles and zeros of z-transform (z^2+0.8z+0.8)/(z^2+0.49),
and sketch the poles zero plot.
EX NO: 04
Z – TRANSFORM
DATE:

AIM:
To write a MATLAB program to find poles and zeros of z – Transform.
PROGRAM:
clear all
syms z
num_coeff=[1 0.8 0.8];
disp('Roots of numerator polynomial z^2+0.8z+0.8 are zeros.');
zeros=roots(num_coeff)
den_coeff=[1 0 0.49];
disp('Roots of denominator polynomial z^2+0.49 are poles.');
poles=roots(den_coeff)
H=tf('z');
TS=0.1;
H=tf([num_coeff],[den_coeff],TS);
zgrid on;
pzmap(H);
OUTPUT:
Roots of numerator polynomial z^2+0.8z+0.8 are zeros.

zeros =

-0.4000 + 0.8000i
-0.4000 - 0.8000i

Roots of denominator polynomial z^2+0.49 are poles.

poles =

0.0000 + 0.7000i
0.0000 - 0.7000i
RESULT:

Thus the matlab program for poles and zeros using z-transform method executed and verified.
Write a MATLAB program to perform 8-point DFT of the discrete time sequence
x(n)= {2,1,2,1,1,2,1,2} and sketch the magnitude and phase spectrum.
EX NO: 05
MAGNITUDE AND PHASE SPECTRUM OF 8 POINT DFT
DATE: SEQUENCE

AIM:
To write a matlab program to perform magnitude and phase spectrum of DFT
sequence.
PROGRAM:
clc;
clear all;
N=8;
j=sqrt(-1);
xn=[2,1,2,1,1,2,1,2];
xk=zeros(1, N);
for k=0:1:N-1
for n=0:1:N-1 xk(k+1)=xk(k+1)+xn(n+1)*exp(-j*2*pi*k*n/N);
end
end
disp('the DFT sequence is.');xk
disp('the magnitude sequence is ,');
magxk=abs(xk)
disp('the phase sequence is,');
phaxk=angle(xk)
wk=0:1:N-1;
subplot(2,1,1)
stem(wk,magxk);
title('magnitude spectrum')
xlabel('k');
ylabel('magxk')
subplot(2,1,2)
stem(wk,phaxk);
title('phase spectrum')
xlabel('k');
ylabel('xk');
OUTPUT:
the DFT sequence

is. xk =

Columns 1 through 5

12.0000 + 0.0000i 1.0000 + 0.4142i -0.0000 - 0.0000i 1.0000 + 2.4142i


0.0000 - 0.0000i

Columns 6 through 8

1.0000 - 2.4142i -0.0000 - 0.0000i 1.0000 - 0.4142i

the magnitude sequence is

, magxk =

12.0000 1.0824 0.0000 2.6131 0.0000 2.6131 0.0000 1.0824

the phase sequence is,

phaxk =

0 0.3927 -2.3201 1.1781 -1.5708 -1.1781 -2.9


RESULT:
Thus the matlab program for magnitude and phase spectrum of DFT sequence was
executed and verified.
Write a MATLAB program to perform 8-point IDFT of the discrete time sequence x(n)={1,1,2,3}
and sketch the magnitude and phase spectrum.
EX NO:06
MAGNITUDE AND PHASE SPECTRUM OF 8 POINT IDFT SEQUENCE
DATE:

AIM:
To write a matlab program to perform magnitude and phase spectrum of IDFT sequence.

PROGRAM:
clc;
clear all;
N=4;
xn=[1,1,2,3];
disp('DFT of the sequence xn is,');
xk=fft(xn,N);
disp('the magnitude sequence xn is,');
magxk=abs(xk)
disp('the phase sequence is,') ;
phaxk=angle(xk)
disp('inverse DFT of the sequence xk is,');
xn=ifft(xk)
n=0:1:N-1;
wk=0:1:N-1;
subplot(2,2,1)
stem(n,xn)
title('input seqence')
xlabel('n');
ylabel('xn');
subplot(2, 2,2)
stem(n,xn)
title('inverse DFT seqence')
xlabel('n');
ylabel('xn');
subplot(2,2,3)
stem(wk,magxk)
title('magnitude spectrum')
xlabel('k');
ylabel('magxk');
subplot(2,2,4)
stem(wk,phaxk)
title('phase spectrum')
xlabel('k');
ylabel('phaxk');
OUTPUT:
DFT of the sequence xn is,
the magnitude sequence xn is,
magxk =
7.0000 2.2361 1.0000 2.2361
the phase sequence is,
phaxk =
0 2.0344 3.1416 -2.0344
inverse DFT of the sequence xk is, xn =
1 1 2 3
RESULT:
Thus the matlab program for magnitude and phase spectrum of IDFT sequence was executed
and verified.
Design a Butterworth digital IIR high pass filter using bilinear transformation by taking
T=0.1second, to satisfy the following specifications.
0.6 < |H(e^jw) | < 1.0 ; for 0.7 pi < w < pi
|H(e^jw) | < 0.1 ; 0 < w < 0.35pi
EX NO:07 SECOND ORDER HIGH PASS FILTER USING BILINEAR
TRANSFORMATION
DATE:

AIM:
To write a MATLAB program to design a butterworth 2nd order high pass filter using bilinear
transformation.
PROGRAM:
clear all;
clc;
AP=0.6;
AS=0.1;
PEF_D=0.35*pi;
SEF_D=0.7*pi;
T=0.1;
alpha_P=-20*log10(AP);
alpha_S=-20*log10(AS);
PEF_A=(2/T)*tan((PEF_D)/2)
SEF_A=(2/T)*tan((SEF_D)/2)
[N, CF]=buttord(PEF_A,SEF_A,alpha_P,alpha_S,'s');
[Bn,An]=butter(N,1,'s');
display('Normalized Transfer functionis,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'high', 's')
display('unnormalized transfer function is,')
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital transfer function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency response is,')
Hw=freqz(num,den,w)
Hw_mag=abs(Hw)
display('magnitude response')
plot(w/pi,Hw_mag,'k');
grid;
title('magnitude response of butterworth 2nd order high pass filter');
xlabel('Normalized frequency');
ylabel('magnitude');
OUTPUT:
PEF_A = 12.2560
SEF_A =39.2522
Normalized Transfer functionis,
Hsn =

1
-----------------
s^2 + 1.414 s + 1
Continuous-time transfer function.
B= 1 0 0
A = 1.0000 17.5983 154.8498
unnormalized transfer function is,
Hs =
s^2
--------------------
s^2 + 17.6 s + 154.8
Continuous-time transfer function.
Digital transfer function is,
Hz =
0.4411 z^2 - 0.8822 z + 0.4411
------------------------------
z^2 - 0.5407 z + 0.2237

Sample time: 0.1 seconds


Discrete-time transfer function.
Frequency response is,
Hw =
Columns 1 through 7
0.0000 + 0.0000i -0.0244 + 0.0056i -0.0908 + 0.0457i -0.1715 + 0.1551i -0.2063 + 0.3488i -0.1252
+ 0.5805i 0.0759 + 0.7517i

Columns 8 through 14
0.3196 + 0.8059i 0.5330 + 0.7652i 0.6922 + 0.6762i 0.8032 + 0.5709i 0.8786 + 0.4646i 0.9295
+ 0.3629i 0.9632 + 0.2666i

Columns 15 through 17
0.9845 + 0.1750i 0.9962 + 0.0867i 1.0000 + 0.0000i
Hw_mag =

Columns 1 through 14
0.0000 0.0251 0.1017 0.2313 0.4052 0.5938 0.7555 0.8670 0.9326 0.9676 0.9854
0.9939 0.9978 0.9994
Columns 15 through 17
0.9999 1.0000 1.0000

magnitude response
RESULT:
Thus the matlab program for second order high pass filter using bilinear transformation
executed and verified.
Design a Butterworth digital IIR low pass filter using bilinear transformation by taking
T=0.1second, to satisfy the following specifications.
0.6 < |H(e^jw) | < 1.0 ; for 0 < w < 0.35 pi

|H(e^jw) | < 0.1 ; for 0.7 < w < pi


EX NO:08
SECOND ORDER LOW PASS FILTER USING BILINEAR TRANSFORMATION
DATE:

AIM:
To write a MATLAB program to design a butterworth 2nd order low pass filter using bilinear
transformation.
PROGRAM:
clear all;
clc;
AP=0.6;
AS=0.1;
PEF_D=0.35*pi;
SEF_D=0.7*pi;
T=0.1;
alpha_P=-20*log10(AP);
alpha_S=-20*log10(AS);
PEF_A=(2/T)*tan((PEF_D)/2)
SEF_A=(2/T)*tan((SEF_D)/2)
[N, CF]=buttord(PEF_A,SEF_A,alpha_P,alpha_S,'s');
[Bn,An]=butter(N,1,'s');
display('Normalized Transfer functionis,')
Hsn=tf(Bn,An)
[B,A]=butter(N,CF,'s')
display('unnormalized transfer function is,')
Hs=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital transfer function is,')
Hz=tf(num,den,T)
w=0:pi/16:pi;
display('Frequency response is,')
Hw=freqz(num,den,w)
Hw_mag=abs(Hw)
display('magnitude response')
plot(w/pi,Hw_mag,'k');
grid;
title('magnitude response of butterworth 2nd order high pass filter');
xlabel('Normalized frequency');
ylabel('magnitude');
OUTPUT:
PEF_A =12.2560
SEF_A =39.2522
Normalized Transfer functionis,
Hsn =
1
-----------------
s^2 + 1.414 s + 1
Continuous-time transfer function.
B=
0 0 154.8498
A=
1.0000 17.5983 154.8498
unnormalized transfer function is,

Hs =
154.8
--------------------
s^2 + 17.6 s + 154.8

Continuous-time transfer function.


Digital transfer function is,
Hz =
0.1708 z^2 + 0.3415 z + 0.1708
------------------------------
z^2 - 0.5407 z + 0.2237

Sample time: 0.1 seconds


Discrete-time transfer function.
Frequency response is,
Hw =
Columns 1 through 7
1.0000 + 0.0000i 0.9743 - 0.2237i 0.8885 - 0.4474i 0.7215 - 0.6526i 0.4654 - 0.7869i
0.1696 - 0.7865i -0.0658 - 0.6518i

Columns 8 through 14
-0.1837 - 0.4632i -0.2063 - 0.2962i -0.1805 - 0.1763i -0.1388 - 0.0987i -0.0972 - 0.0514i
-0.0617 - 0.0241i -0.0343 - 0.0095i

Columns 15 through 17
-0.0151 - 0.0027i -0.0037 - 0.0003i -0.0000 - 0.0000i
Hw_mag =

Columns 1 through 14
1.0000 0.9997 0.9948 0.9729 0.9142 0.8046 0.6551 0.4983 0.3610 0.2523
0.1703 0.1099 0.0663 0.0356

Columns 15 through 17
0.0153 0.0038 0.0000
magnitude response
RESULT:

Thus the matlab program for second order low pass filter using bilinear transformation
executed and verified.
Design a Chebyshev digital IIR low pass filter using impulse invariant transformation by taking
T=1second, to satisfy the following specifications..
0.9 < |H(e^jw) | < 1.0 ; for 0 < w < 0.25 pi

|H(e^jw) | < 0.24 ; for 0.5 < w < pi


EX NO:09
CHEBYSHEV THIRD ORDER LOW PASS FILTER USING IMPULSE
DATE: INVARIANT TRANSFORMATION

AIM:
To write a matlab program to perform chebyshev third order low pass filter using impulse
invariant transformation.
PROGRAM:
clear all;
clc;
AP=0.9;
AS=0.24;
PEF_D=0.25*pi;
SEF_D=0.5*pi;
T=1;
alpha_P=-20*log10(AP)
alpha_S=-20*log10(AS)
PEF_A=PEF_D/T
SEF_A=SEF_D/T
[N,CF]=cheb1ord(PEF_A,SEF_A,alpha_P,alpha_S,'s');
[Bn,An]=cheby1(N,alpha_P,1,'s');
display('Normalized transfer functionis,')
HSn=tf(Bn,An)
[B,A]=cheby1(N,alpha_P,CF,'s')
display('Unnormalized Transfer functionis,')
HS=tf(B,A)
[num,den]=impinvar(B,A,1/T);
display('Digital Transferfunction is,');
HZ=tf(num,den,T)
w=0:pi/16:pi;
display('Frequencyresponse is,');
Hw=freqz(num,den,w)
display('magnituderesponse is');
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');grid;
title('magnitude response of chebychev third orderlowpass filter');
xlabel('Normalizedfrequency,\omega/\pi');
ylabel('Magnitude');
OUTPUT:
alpha_P = 0.9151
alpha_S = 12.3958
PEF_A =0.7854
SEF_A = 1.5708
Normalized transfer functionis,
HSn =
0.5162
----------------------------------
s^3 + 1.021 s^2 + 1.272 s + 0.5162
Continuous-time transfer function,
B=
0 0 0 0.2501
A=
1.0000 0.8022 0.7844 0.2501

Unnormalized Transfer functionis,

HS =
0.2501
------------------------------------
s^3 + 0.8022 s^2 + 0.7844 s + 0.2501

Continuous-time transfer function.

Digital Transferfunction is,

HZ =
0.09112 z^2 + 0.06993 z
----------------------------------
z^3 - 1.852 z^2 + 1.461 z - 0.4484

Sample time: 1 seconds


Discrete-time transfer function.
Frequencyresponse is,
Hw =
Columns 1 through 7
0.9997 + 0.0000i 0.7886 - 0.5273i 0.4090 - 0.8019i -0.1055 - 0.9597i -0.7930 - 0.4270i -0.4297 +
0.1435i -0.1730 + 0.1408i
Columns 8 through 14
-0.0814 + 0.0955i -0.0438 + 0.0642i -0.0260 + 0.0442i -0.0167 + 0.0311i -0.0114 + 0.0221i -0.0083
+ 0.0155i -0.0064 + 0.0106i
Columns 15 through 17
-0.0052 + 0.0066i -0.0046 + 0.0032i -0.0045 + 0.0000i
magnituderesponse is
Hw_mag =
Columns 1 through 14
0.9997 0.9487 0.9002 0.9655 0.9007 0.4531 0.2230 0.1255 0.0778 0.0513 0.0353
0.0248 0.0176 0.0124
Columns 15 through 17

0.0084 0.0056 0.0045


RESULT:

Thus the matlab program for chebyshev third order low pass filter using impulse invariant
transformation was executed and verified .
Design a Chebyshev digital IIR low pass filter using bilinear transformation by taking T=1second,
to satisfy the following specifications..
0.8 < |H(e^jw) | < 1.0 ; for 0 < w < 0.2 pi

|H(e^jw) | < 0.2 ; for 0.32pi < w < pi


EX NO:10
CHEBYSHEV THIRD ORDER LOW PASS FILTER USING BILINEAR
DATE: TRANSFORMATION

AIM:
To write a matlab program to perform chebyshev third order low pass filter using bilinear
transformation.
PROGRAM:
clear all;
clc;
AP=0.8;
AS=0.2;
PEF_D=0.2*pi;
SEF_D=0.32*pi;
T=1;
alpha_P=-20*log10(AP)
alpha_S=-20*log10(AS)
PEF_A=(2/T)*tan(PEF_D/2)
SEF_A=(2/T)*tan(SEF_D/2)
[N,CF]=cheb1ord(PEF_A,SEF_A,alpha_P,alpha_S,'s');
[Bn,An]=cheby1(N,alpha_P,1,'s');
display('Normalized transfer functionis,')
HSn=tf(Bn,An)
[B,A]=cheby1(N,alpha_P,CF,'s')
display('Unnormalized Transfer functionis,')
HS=tf(B,A)
[num,den]=bilinear(B,A,1/T);
display('Digital Transferfunction is,');
HZ=tf(num,den,T)
w=0:pi/16:pi;
display('Frequencyresponse is,');
Hw=freqz(num,den,w)
display('magnituderesponse is');
Hw_mag=abs(Hw)
plot(w/pi,Hw_mag,'k');grid;
title('magnitude response of chebychev third orderlowpass filter');
xlabel('Normalizedfrequency,\omega/\pi');
ylabel('Magnitude');
OUTPUT:
alpha_P =1.9382
alpha_S =13.9794
PEF_A = 0.6498
SEF_A =1.0995
Normalized transfer functionis,
HSn =
0.3333
----------------------------------
s^3 + 0.7489 s^2 + 1.03 s + 0.3333

Continuous-time transfer function.


B=
0 0 0 0.0915
A=
1.0000 0.4867 0.4351 0.0915
Unnormalized Transfer functionis,

HS =
0.09147
-------------------------------------
s^3 + 0.4867 s^2 + 0.4351 s + 0.09147

Continuous-time transfer function.


Digital Transferfunction is,

HZ =
0.008386 z^3 + 0.02516 z^2 + 0.02516 z + 0.008386
-------------------------------------------------
z^3 - 2.274 z^2 + 1.967 z - 0.6263

Sample time: 1 seconds


Discrete-time transfer function.

Frequencyresponse is,
Hw =
Columns 1 through 7
1.0000 + 0.0000i 0.5843 - 0.6284i 0.1071 - 0.8164i -0.8586 - 0.3985i -0.2173 + 0.1864i -0.0539 +
0.0878i -0.0184 + 0.0427i
Columns 8 through 14
-0.0073 + 0.0223i -0.0031 + 0.0120i -0.0014 + 0.0065i -0.0006 + 0.0035i -0.0002 + 0.0018i -0.0001
+ 0.0008i -0.0000 + 0.0003i
Columns 15 through 17
-0.0000 + 0.0001i -0.0000 + 0.0000i -0.0000 - 0.0000i
magnituderesponse is
Hw_mag =
Columns 1 through 14
1.0000 0.8581 0.8234 0.9466 0.2863 0.1030 0.0465 0.0234 0.0124 0.0067 0.0035
0.0018 0.0008 0.0003
Columns 15 through 17
0.0001 0.0000 0.0000
RESULT:

Thus the matlab program for chebyshev third order low pass filter using bilinear
transformation was executed and verified .
Design a linear phase FIR Low-pass filter using rectangular window, with a cutoff frequency,

ωc = 0.2𝜋 rad/sample and N = 7.


EX NO:11
DETERMINE THE IMPULSE RESPONSE OF FIR LOW PASS FILTER USING
DATE: RECTANGULAR WINDOW METHOD

AIM:
To Design and the impulse response of FIR Low pass filter using rectangular window method.
PROGRAM:

clear all;
clc;
wc = 0.2*pi;
N = 7;
hd = zeros(1, N);
hna = (wc/pi);
k = 1:1:((N - 1)/2);
n = k - 1 - ((N - 1)/2);
hd(k) = (sin(wc * n))./ (pi * n);
hn(k) = hd(k);
hn = [hn hna];
a = (N - 1)/2;
w = 0:pi/16:pi;
Hw1 = hna * exp(-j * w * a);
Hw2 = 0;
for m = 1:1:a
Hw3 = hn(m) * (exp(j * w * (1 - m)) + exp(-j * w * (1 - m + 2 * a)));
Hw2 = Hw2 + Hw3;
end
Hw = Hw2 + Hw1;
H_mag = abs(Hw);
plot(w/pi, H_mag, 'k');
grid;
title('magnitude response', 'fontweight', 'b');
xlabel('noramlised frequency, \omega/\pi', 'fontweight', 'b');
ylabel('magnitude', 'fontweight', 'b');
OUTPUT:
hn = 0.100910230485421 0.151365345728131 0.187097856757728 0.20000
Hw = Columns 1 through 2
1.078746865942560 + 0.000000000000000i 0.843525853453463 -0.563625955810249i
Columns 3 through 4
0.320309106755305 - 0.773294589680268i -0.114636861455628 - 0.576318420849239i
Columns 5 through 6
-0.227608982509616 - 0.227608982509616i -0.092291347862352 - 0.018357890491960i
Columns 7 through 8
0.052958823885729 - 0.021936263100797i 0.066007392711047 - 0.098787044309876i
Columns 9 through 10
0.000000000000000 - 0.102730691456263i -0.022535712818700 - 0.033727077670241i
Columns 11 through 12
0.026973927102073 + 0.011172966436142i 0.072774775424032 -0.014475802865117i
Columns 13 through 14
0.055233729965003 - 0.055233729965003i 0.008601702800197 - 0.043243680186962i
Columns 15 through 16
0.003399064198578 + 0.008206066887583i 0.045836041631309 +0.030626663864820i
Column 17
0.073285483030035 + 0.000000000000000i
H_mag = Columns 1 through 4
1.078746865942560 1.014499917943521 0.837008032398229 0.587609166210465
Columns 5 through 8
0.321887709983040 0.094099442259582 0.057322217910571 0.118810167982340
Columns 9 through 12
0.102730691456263 0.040563211416522 0.029196368306540 0.074200517562939
Columns 13 through 16
0.078112290016960 0.044090873967014 0.008882182794197 0.055126538544659
Column 17
0.07328548303003
RESULT:

Thus the impulse response of FIR Low pass filter using rectangular window method has
verified.
Design a linear phase FIR highpass filter using hamming window, with a cutoff frequency,

ωc = 0.8𝜋 rad/sample and N = 7.


EX NO:12
DETERMINE THE IMPULSE RESPONSE OF FIR HIGH PASS FILTER USING
DATE: HAMMING WINDOW METHOD

AIM:
To Design and implementation of FIR filter using rectangular window method
PROGRAM:

clear all;
clc;
wc = .8*pi;
N = 7;
hd = zeros(1, N);
a = (N - 1)/2;
hna = 1 - (wc/pi);
k = 1:1:((N - 1)/2);
n = k - 1 - ((N - 1)/2);
w_ham(k) = .54 - .46 * cos(2*pi*(k - 1)/(N - 1));
hd(k) = (-sin(wc * n))./ (pi * n);
for s = 1:length(k)
hn(s) = hd(s) * w_ham(s);
end
hn = [hn hna];
a = (N - 1)/2;
w = 0:pi/16:pi;
Hw1 = hna * exp(-j * w * a);
Hw2 = 0;
for m = 1:1:a
Hw3 = hn(m) * (exp(j * w * (1 - m)) + exp(-j * w * (1 - m + 2 * a)));
Hw2 = Hw2 + Hw3;
end
Hw = Hw2 + Hw1;
H_mag = abs(Hw);
plot(w/pi, H_mag, 'k');
grid;
title('magnitude response', 'fontweight', 'b');
xlabel('noramlised frequency, \omega/\pi', 'fontweight', 'b');
ylabel('magnitude', 'fontweight', 'b');
OUTPUT:
hn = -0.0081 0.0469 -0.1441 0.2000
Hw =
Columns 1 through 7
-0.0104 + 0.0000i -0.0077 + 0.0052i -0.0023 + 0.0056i 0.0001 + 0.0005i -0.0054 - 0.0054i
-0.0195 - 0.0039i -0.0354 + 0.0147i
Columns 8 through 14
-0.0367 + 0.0549i -0.0000 + 0.1062i 0.0892 + 0.1335i 0.2116 + 0.0876i 0.3024 - 0.0602i
0.2774 - 0.2774i 0.0921 - 0.4633i
Columns 15 through 17
-0.2062 - 0.4977i -0.4845 - 0.3237i -0.5981 - 0.0000i
H_mag =
Columns 1 through 14
0.0104 0.0093 0.0060 0.0005 0.0077 0.0198 0.0383 0.0661 0.1062 0.1605
0.2290 0.3083 0.3923 0.4723
Columns 15 through 17
0.5387 0.5827 0.5981
RESULT:

Thus the impulse response of FIR high pass filter using hamming window method was
verified.
Design a linear phase FIR band-pass filter to pass frequencies in the range 0.4π to 0.65π
rad/sample by taking 7 samples of Hanning window sequence.
EX NO:13
DETERMINE THE IMPULSE RESPONSE OF FIR BAND PASS FILTER USING
DATE: HANNING WINDOW METHOD

AIM:
To Design and implementation of FIR Band pass filter using Hanning window method.
PROGRAM:

clear all;
clc;
wc1 = 0.4*pi;
wc2 = 0.65*pi;
N = 7;
hd = zeros(1, N);
a = (N - 1)/2;
hna = ((wc2-wc1)/pi);
k = 1:1:((N - 1)/2);
n = k - 1 - ((N - 1)/2);
w_han(k)=.5-.5*cos(2*pi*(k-1)/(N-1));
hd(k) = (sin(wc2 * n)-sin(wc1*n))./ (pi * n);
for s=1:length(k)
hn(s)=hd(s)*w_han(s);
end
hn = [hn hna];
a = (N - 1)/2;
w = 0:pi/16:pi;
Hw1 = hna * exp(-j * w * a);
Hw2 = 0;
for m = 1:1:a
Hw3 = hn(m) * (exp(j * w * (1 - m)) + exp(-j * w * (1 - m + 2 * a)));
Hw2 = Hw2 + Hw3;
end
Hw = Hw2 + Hw1;
H_mag = abs(Hw);
plot(w/pi, H_mag, 'k');
grid;
title('magnitude response', 'fontweight', 'b');
xlabel('noramlised frequency, \omega/\pi', 'fontweight', 'b');
ylabel('magnitude', 'fontweight', 'b');
OUTPUT:
hn = 0 -0.055576995519746 -0.014335879614636 0.25000
Hw = Columns 1 through 3
0.110174249731235 + 0.000000000000000i 0.099099756143106 -0.066216340077836i
0.055455807168360 - 0.133882161778201i
Columns 4 through 6
-0.035823170214091 - 0.180095238350445i -0.162440815682001 - 0.162440815682001i
-0.271292677098193 - 0.053963468654367i
Columns 7 through 9
-0.293447729483239 + 0.121550029399549i -0.192838047058555 +
0.288602532488993i -0.000000000000000 + 0.361153991039492i
Columns 10 through 12
0.199053303192005 + 0.297904320634756i 0.313721724862806 +
0.129947793249255i 0.302538879711564 - 0.060178724787816i
Columns 13 through 15
0.191112574911273 - 0.191112574911273i 0.045124958359854 - 0.226858485243028i
-0.075729802547927 - 0.182827916387041i
Columns 16 through 17
-0.145863003035690 - 0.097462542691206i -0.167517768189780 - 0.000000000000000i
H_mag =
Columns 1 through 6
0.110174249731235 0.119186263306334 0.144913007667010 0.183623512657533
0.229726004620433 0.276607614855982
Columns 7 through 12
0.317625533586170 0.347099314537522 0.361153991039492 0.358286480019138
0.339569948053777 0.308465966768160
Columns 13 through 17
0.270273995379567 0.231302905718324 0.197891510693043 0.175427942137006
0.167517768189780
RESULT:

Thus the impulse response of FIR band pass filter using hanning window method was
verified.
Design a linear phase FIR band-stop filter to pass frequencies in the range 0.4π to 0.65π
rad/sample by taking 7 samples of rectangular window sequence.
EX NO:14
DETERMINE THE IMPULSE RESPONSE OF FIR BAND-STOP FILTER USING
DATE: RECTANGULAR WINDOW METHOD

AIM:
To Design and implementation of FIR Band-stop filter using rectangular window method.
PROGRAM:

clear all;
clc;
wc1 = 0.4*pi;
wc2 = 0.65*pi;
N = 7;
hd = zeros(1, N);
a = (N - 1)/2;
hna = 1-((wc2-wc1)/pi);
k = 1:1:((N - 1)/2);
n = k - 1 - ((N - 1)/2);
hd(k) = (sin(wc1 * n)-sin(wc2*n))./ (pi * n);
hn(k) = hd(k);
hn = [hn hna];
a = (N - 1)/2;
w = 0:pi/16:pi;
Hw1 = hna * exp(-j * w * a);
Hw2 = 0;
for m = 1:1:a
Hw3 = hn(m) * (exp(j * w * (1 - m)) + exp(-j * w * (1 - m + 2 * a)));
Hw2 = Hw2 + Hw3;
end
Hw = Hw2 + Hw1;
H_mag = abs(Hw);
plot(w/pi, H_mag, 'k');
grid;
title('magnitude response', 'fontweight', 'b');
xlabel('noramlised frequency, \omega/\pi', 'fontweight', 'b');
ylabel('magnitude', 'fontweight', 'b');
OUTPUT:
hn = -0.045767739998517 0.222307982078985 0.019114506152848 0.75000
Hw = Columns 1 through 3
1.141309496466634 + 0.000000000000000i 0.933039505267509 - 0.623437065754540i
0.407435723440063 - 0.983636849324294i
Columns 4 through 6
-0.189196860242099 - 0.951156847281321i -0.595212332041276 - 0.595212332041276i -
0.677593547060830 - 0.134781736567050i
Columns 7 through 9
-0.494096689433424 + 0.204661549886971i -0.220861895536440 + 0.330543185613059i -
0.000000000000000 + 0.305384035842030i
Columns 10 through 12
0.156068519029924 + 0.233573044950853i 0.310803856971901 + 0.128739172795629i
0.459828707111448 - 0.091465616720665i
Columns 13 through 15
0.465447839738545 - 0.465447839738545i 0.169826752518570 - 0.853776739756093i -
0.407213850972606 - 0.983101201804242i
Columns 16 through 17
-0.997253101076214 - 0.666343218737903i -1.247922431849306 - 0.00000i
H_mag =
Columns 1 through 6
1.141309496466634 1.122157071602041 1.064680853628800 0.969791111557335
0.841757352464490 0.690868389442234
Columns 7 through 12
0.534806402833031 0.397540909159270 0.305384035842030 0.280915912614090
0.336411670607178 0.468837284061195
Columns 13 through 17
0.658242647535510 0.870503214939237 1.064101072930991 1.199386106624599
1.2479224318
RESULT:

Thus the impulse response of FIR band-stop filter using rectangular window method was
verified.

You might also like