You are on page 1of 33

Digital Signal Processing Lab

2014

LAB MANNUAL
DIGITAL SIGNAL PROCESSING (EC-603)
Submit By
Name-..
Roll no-
Session -.

Submit to
Prof.

Prof. Prateek Mishra

Asst. professor

HOD

EC Dept. GNCSGI

EC Dept. GNCSGI

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING, GNCSGI

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 1

Digital Signal Processing Lab

2014

GLOBAL NATURE CARE SANGATHANS GROUP


OF INSTITUTION, JABALAPUR
Digital signal processing
(EC- 603)

List of Experiments
1. To plot and demonstrate various types of discrete time signals.
2. To plot and demonstrate shifting of discrete time signals.
3. To plot and demonstrate addition, subtraction multiplication of
discrete time signals.
4. To find the impulse response of a discrete time system described
by difference equation and also find its stability.
5. Implement an M-Point moving average filter.
6. Implementation of an integrator and differentiator.
7. To Sketch Pole zero plot of a given transfer function.
8. Finding the Discrete time Fourier Transform of a given impulse
response and verify its convolution property.
9. To verifying the convolution property of DTFT.
10. To implement FIR Low Pass Filter Using Windowing
11. To implement FIR High Pass Filter Using Windowing

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 2

Digital Signal Processing Lab

2014

EC 603 Digital Signal Processing


Unit I
Discrete-Time Signals and Systems Discrete-time signals, discretetime systems, analysis of discrete-time linear time-invariant
systems, discrete time systems described by difference equation,
solution of difference equation, implementation of discrete-time
systems, stability and causality, frequency domain representation
of discrete time signals and systems.
Unit - II
The z-Transform The direct z-transform, properties of the
transform, rational z-transforms, inversion of the z transform,
analysis of linear time-invariant systems in the z- domain, block
diagrams and signal flow graph representation of digital network,
matrix representation.
Unit - III
Frequency Analysis of Discrete Time Signals Discrete fourie series
(DFS), properties of the DFS, discrete Fourier transforms (DFT)
properties of DFT, two dimensional DFT, circular convolution.
Unit - IV
Efficient Computation of the DFT- FFT algorithms, decimation in
time algorithm, decimation in frequency algorithm, decomposition
for N composite number.
Unit - V
Digital filters Design Techniques Design of IIR and FIR digital
filters, Impulse invariant and bilinear transformation, windowing
techniques- rectangular and other windows, examples of FIR
filters, design using windowing.

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 3

Digital Signal Processing Lab

2014

Experiment detail
S no.

Object

To plot and demonstrate various types of discrete time


signals.

To plot and demonstrate shifting of discrete time signals.

To plot and demonstrate addition, subtraction


multiplication of discrete time signals.

To find the impulse response of a discrete time system


described by difference equation and also find its stability.

5
6
7
8
9

Pg no

Implement an M-Point moving average filter.


Implementation of an integrator and differentiator.
To Sketch Pole zero plot of a given transfer function.
Finding the Discrete time Fourier Transform of a given
impulse response and verify its convolution property.
To verifying the convolution property of DTFT.

10

To implement FIR Low Pass Filter Using Windowing

11

To implement FIR High Pass Filter Using Windowing

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 4

Digital Signal Processing Lab

2014

1. Demonstration of basic discrete time signals.


Aim:- To plot and demonstrate various types of discrete time signals.
Equipments:Operating System Windows XP or above version
Constructor script or Simulator
Software - MATLAB 7 or above version

Theory:-

We use several elementary sequences in digital signal processing for analysis


purposes. Their definitions and MATLAB representations are given below.

1. Unit sample sequence:-

(n) = {

= {..,0,0,0,1,0,0,0,..

In MATLAB t he function zeros (1, N) generates a row vector of N zeros, which can be used to
implement (n) over a finite interval. However, the implementing (n) can be done by taking
n=0 sample equal to 1.

Program:% Digital Signal Processing Lab


% Program to generate a unit impulse signal
N=64;
n=-(N/2): ((N/2)-1);
x=zeros(1,N);
x((N/2)+1)=1;
stem(n,x);
grid;
title('A unit impulse signal ');
xlabel('Sampel Number');
ylabel('Amplitude');

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 5

Digital Signal Processing Lab

2014

2. Unit step sequence:u(n) = {


In MATLAB t he function ones (1, N) generates a row vector of N ones. It can be used to
generate u(n) over a finite interval.

Program:% Digital Signal Processing Lab


% Program to generate a unit step signal
n=-20:20;
u=[zeros(1,20),ones(1,21)];
stem(n,u);
grid;
title('A unit step signal ');
xlabel('Sampel Number');
ylabel('Amplitude');

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 6

Digital Signal Processing Lab

2014

3. Real-valued exponential sequence:x(n) = ()n ,


In MATLAB an array operator " . ^ " is required to implement a real exponential sequence.
For example, to generate z(n) = (0.9)n , 0 < n < 10, we will need the following MATLAB script:
>> n=0:10; x=(0.9).^n;

Program:% Digital Signal Processing Lab


% Program to generate a real valued exponential signal
% x(n)=(0.9).^n
n=0:40;
x=(0.9).^n;
stem(n,x);
grid;
title('A Real valued Exponential signal ');
xlabel('Sampel Number');
ylabel('Amplitude');

4. Sinusoidal sequence:x(n) = cos (o n + )


where o = 2 /N where N is period of this discrete time
sinusoid. Where is the phase in radians, a MATLAB function cos (or sin) is used to generate
sinusoidal sequences.

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 7

Digital Signal Processing Lab

2014

Program:% Digital Signal Processing Lab


% Program to generate a sinusoidal signal
% x(n)=A*cos((2*pi/N)+ theta)in this example N=12 and theta is pi/3
n=0:40;
x=2*cos((2*(pi/12)*n)+pi/3);
stem(n,x);
grid;
title('A sinusoidal signal of period N=12');
xlabel('Sample Number');
ylabel('Amplitude');

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 8

Digital Signal Processing Lab

2014

2. Demonstration of shifting of discrete time signals.


Aim:- To plot and demonstrate shifting of discrete time signals.
Equipments:Operating System Windows XP
Constructor - Simulator
Software - MATLAB 7

Theory:-

Shifting is any discrete time sequence can be seen as delaying or advancing the
sequence in time or sample interval if x(n) is a discrete time signal than its delayed version can
be expressed as x(n- no) where no is amount of shift. To implement this using MATLAB we have
to pad no numbers of zeros before starting the sequence x(n).

Program:% Digital Signal Processing Lab


% Program to generate a sinusoidal signal and delay it by 10 samples
% x(n)=A*cos((2*pi/N)+ theta)in this example N=12 and theta is 0 and
% amount of delay is of 20 samples
N=64
n=0:N-1;
x=2*cos(2*(pi/12)*n);
xd =[zeros(1,20), x(1:(N-20))];
subplot(2,1,1);
stem(n,x);
grid;
title('A sinusoidal signal of period N=12');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(2,1,2);
stem(n,xd);
grid;
title('A delayed sinusoidal signal of period N=12 amount of delay =20');
xlabel('Sample Number');
ylabel('Amplitude');
% in this section we will generate a delayed unit impulse sequence
% delayed by 20 samples
m=-(N/2): ((N/2)-1);
u=zeros(1,N);
u((N/2)+1)=1;
ud=[zeros(1,20),u(1:N-20)];
figure(2)
subplot(1,2,1)
stem(m,u);
Digital Signal Processing Lab

GNCSGI Jabalpur

Page 9

Digital Signal Processing Lab

2014

grid;
title('A unit impulse signal ');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(1,2,2)
stem(m,ud);
grid;
title('A unit impulse signal delayed by 20 samples');
xlabel('Sample Number');
ylabel('Amplitude');

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 10

Digital Signal Processing Lab

2014

3. Demonstration basic manipulation on discrete time signals.

Aim:- To plot and demonstrate addition, subtraction multiplication of discrete


time signals.

Equipments:Operating System Windows XP


Constructor - Simulator
Software - MATLAB 7

Theory:1. Signal addition: - This is a sample -by-sample addition given by x1(n) + x2(n) it is

implemented in MATLAB by the arithmetic operator +. However, the lengths of x 1(n)


and x2(n) must be the same.
2. Signal subtraction:- This is a sample -by-sample subtraction given by x1(n) - x2(n)
It is implemented in MATLAB by the arithmetic operator -. However, the lengths of
x1(n) and x2(n) must be the same.
3. Signal subtraction:- This is a sample -by-sample multiplication given by x1(n) *x2(n)
It is implemented in MATLAB by the arithmetic operator *. However, the lengths of
x1(n) and x2(n) must be the same. This operation is non linear operation whereas addition
and subtraction are linear operations.

Program :% Digital Signal Processing Lab


% Program to demonstrate addition subtraction and multiplication
% of two different sinusoids having periods N1=15 and N2=30
n=0:50;
x1=cos(2*pi/15*n);
x2=0.5*sin(2*pi/30*n);
add=x1+x2;
sub=x1-x2;
mul=x1 .* x2;
subplot(1,2,1);
stem(n,x1);
grid;
title('A sinusoidal signal of N=15');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(1,2,2);
stem(n,x2);
Digital Signal Processing Lab

GNCSGI Jabalpur

Page 11

Digital Signal Processing Lab

2014

grid;
title('A sinusoidal signal of N = 30');
xlabel('Sample Number');
ylabel('Amplitude');
figure(2);
subplot(1,3,1);
stem(n,add);
grid;
title('A addition x1+x2');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(1,3,2);
stem(n,sub);
grid;
title('A subtraction x1-x2');
xlabel('Sample Number');
ylabel('Amplitude');
subplot(1,3,3);
stem(n,mul);
grid;
title('A multiplication x1*x2');
xlabel('Sample Number');
ylabel('Amplitude');

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 12

Digital Signal Processing Lab

Digital Signal Processing Lab

GNCSGI Jabalpur

2014

Page 13

Digital Signal Processing Lab

2014

4. Finding impulse response of a given discrete time system and

finding its stability.


Aim:- To find the impulse response of a discrete time system described by
difference equation and also find its stability.

Equipments:Operating System Windows XP


Constructor - Simulator
Software - MATLAB 7

Theory:-

Impulse response of a given system described by a difference equation can be


found by using MATLAB function impz(num,den,N) where num is a row vector of coefficient
of input x(n) = (n) and its delayed forms, similarly den is a row vector of coefficients of out
put y(n) and its delayed forms. And N is total number of samples for which we have to find
response.
Where as the test of stability of a system can be performed using the method Sum of
Absolute Test in this method after finding impulse response of a system for N samples we test
the absolute value of h(n) i.e. impulse response, if the absolute value is decreasing as N is
increasing and if the absolute value of h(n) becomes < 10-6 the system can be considered as
stable system.

Program:% Digital Signal Processing Lab


% Program to find impulse response of a system
% y(n)+ 1.5 y(n-1)+ 0.9 y(n-2)= x(n)- 0.8 x(n-1)
clc;
N=200;
n=0:N;
num = [1 -0.8];
den = [1 1.5 0.9];
h = impz(num,den,N+1);
stem(n,h);
xlabel('Time index n');
ylabel('Amplitude');
title('Impulse Response h(n)');
sum = 0;
for K=1:N+1;
sum = sum + abs(h(K));
if abs(h(K))< 10^-6;
break
end
end
stem(n,h);
Digital Signal Processing Lab

GNCSGI Jabalpur

Page 14

Digital Signal Processing Lab

2014

xlabel('Time index n');


ylabel('Amplitude');
title('Impulse Response h(n)');
grid;
disp('value = ');
disp(abs(h(K)));
disp('sum of h(n) from n = 0 to N = ')
disp(sum);

Out Put:value =
1.6761e-0.05
sum of h(n) from n = 0 to N =
35.3591

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 15

Digital Signal Processing Lab

2014

5. M-Point Moving Average Filter

Aim:- Implement an M-Point moving average filter.


Equipments:Operating System Windows XP
Constructor - Simulator
Software - MATLAB 7

Theory: - an M pint moving average filter can be described as below.


( )

This can be implemented using MATLAB function filter and the matlab script to implement
this can be written as: >> y=filter(num,1,x);
Where x(n) is input and num is a row vector of all the elements 1 and it is a 1xM matrix, and 1 is
denominator co efficient.

Program:% Digital Signal Processing Lab


% Program to impliment M point moving average filter
% y(n)= 1/M(x(n)+ x(n-1)+x(n-2)+ x(n-3)+x(n-4)+ ......+x(n-M))
close all;
clear all;
clc;
clf;
n= 0:56;
s1=cos(2*pi*0.05*n);
s2=cos(2*pi*0.5*n);
s=s1+s2;
subplot(2,2,1);
plot(n,s1);
grid;
title('Orignal signal s1 ,N=20 ');
xlabel('number of sampel');
ylabel('Amplitude');
subplot(2,2,2);
plot(n,s2);
grid;
title('Additive Noise signal s2 ,N=2 ');
xlabel('number of sampel');
ylabel('Amplitude');
subplot(2,2,3);
plot(n,s);
grid;
title('Noisy signal to be filtered = s1+s2 ');
Digital Signal Processing Lab

GNCSGI Jabalpur

Page 16

Digital Signal Processing Lab

2014

xlabel('number of sampel');
ylabel('Amplitude');
M=input('Please enter the length of filter = ');
num=ones(1,M);
y=filter(num,1,s)/M;
subplot(2,2,4);
plot(n,y);
grid;
title(' Filtered signal ');
xlabel('number of sampel');
ylabel('Amplitude');
Please enter the length of filter = 10

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 17

Digital Signal Processing Lab

2014

6. Implementation of integrator and differentiator

Aim:- implementation of an integrator and differentiator.


Equipments:Operating System Windows XP
Constructor - Simulator
Software - MATLAB 7

Theory: - In digital signal processing a differentiator and integrator can be synthesized using
difference equations,
1. Differentiator:- a differentiator can be implemented using finding the first difference of
any given input signal x(n) and it is given as:
y(n) = x(n)-x(n-1) this is called the first difference of input x(n).
2. Integrator or Accumulator:- An integrator can be viewed as :

y(n)=

( ) and this can be converted in to difference equation as:

simulation of Integration Using Trapezoidal rule y(n)=y(n-1)+1/2(x(n)+x(n-1))

Program:% Digital Signal Processing Lab


% Program to find integration and differentiation of a given signal x(n)
% the integrator can be implemented using y(n)- y(n-1)= x(n)
% and differentiation can be implemented using y(n)= x(n)- x(n-1)
% in this program we will use x(n)= u(n)i.e. unit step signal
n=-50:50;
u=[zeros(1,50) ones(1,51)];
axis([-50,50,0,1]);
subplot(3,1,1);
stem(n,u);
grid;
title('imput unit step signal');
xlabel('sampel number');
ylabel('Amplitude');
% implementing differentiation y(n)= x(n)- x(n-1)
num1=[1,-1];
den1=[1];
yd=filter(num1,den1,u);
subplot(3,1,2);
stem(n,yd);
grid;
title('Differentiation of unit step signal is impulse signal');
xlabel('sampel number');
ylabel('Amplitude');
% implementing integration y(n)- y(n-1)= x(n)+ x(n-1)
num2=[1/2,1/2];
Digital Signal Processing Lab

GNCSGI Jabalpur

Page 18

Digital Signal Processing Lab

2014

den2=[1 ,-1];
yi=filter(num2,den2,u);
subplot(3,1,3);
stem(n,yi);
grid;
title('Integration of unit step signal is unit ramp signal');
xlabel('sampel number');
ylabel('Amplitude');

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 19

Digital Signal Processing Lab

2014

7. Z transform and pole zero plot

Aim:- Sketching Pole zero plot of a given transfer function.


Equipments:Operating System Windows XP
Constructor - Simulator
Software - MATLAB 7

Theory:- Assume we have a transfer function in the z-domain given by:X z

z 1
z
2
1
2
1 0.25 z 0.375 z
z 0.25 z 0.375

Factoring this, its partial fraction expansion can be found to be:c1 z


c2 z
z
0.8 z
0.8 z
X z

z 0.75 z 0.5 z 0.75 z 0.5 z 0.75 z 0.5


The inverse z-transform of this is thus:-

xn 0.80.75 0.8 0.5 u n


n

There are several MATLAB functions that could assist with calculating and analyzing these
results. We can find the roots of the denominator polynomial using,
den = [1 -0.25 -0.375]; roots(den)
We can then plot the zeros and poles either with
1. Zeros and poles in column vectors
zplane(z,p) z = [0] p = [0.75; -0.5]
2. numerator and denominator coefficients in row vectors
num = [0 1 0]

den = [1 -0.25 -0.375]

zplane(num,den)

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 20

Digital Signal Processing Lab

2014

Program:-

% Digital Signal Processing Lab


% Program to show pole zero location in complex z plane
% for a given transfer function,Described in theory
clc;
close all;
clear all;
num=[0];
den=[1,-0.25,-0.375];
z=roots(num);
p=roots(den);
% Pole zero plot using Zeros and poles in column vectors
zplane(z,p);
title('Pole zero plot using Zeros and poles in column vectors');
figure(2);
%Pole zero plot using numerator and denominator coefficients in row vectors
zplane(num,den);
title('Pole zero plot using numerator and denominator coefficients in row vectors');

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 21

Digital Signal Processing Lab

Digital Signal Processing Lab

GNCSGI Jabalpur

2014

Page 22

Digital Signal Processing Lab

2014

8. Discrete time Fourier Transform and its Convolution

property
Aim: - Finding the Discrete time Fourier Transform of a given impulse response
and verify its convolution property.

Equipments:Operating System Windows XP


Constructor - Simulator
Software - MATLAB 7

Theory:- As we know that DTFT of a discrete time signal is continuous and


periodic in nature having period 2 . In matlab using function freqz we can
compute H(ei) i.e. the Fourier transform of any given system described by
difference equation , and we can plot its real value and imaginary value and with
respect to frequency in radian and we can also plot the magnitude spectrum and
phase spectrum of that system.

Program:% Digital signal processing Lab


% Program to find DTFT of a given system described by difference equation
% y(n)- 0.6 y(n-1)= 2 x(n)+ x(n-1)
close all;
clear all;
clc;
clf;
% computing the frequency samples of the DTFT
w=-4*pi:8*pi/511:4*pi;
num=[2 1]; den=[1 -0.6];
H=freqz(num,den,w);
% plot the DTFT
subplot(2,1,1);
plot(w/pi, real(H)); grid;
title('Real part of H(e^{j\omega})');
xlabel('\omega/\Pi');
ylabel('Amplitude');
subplot(2,1,2);
Digital Signal Processing Lab

GNCSGI Jabalpur

Page 23

Digital Signal Processing Lab

2014

plot(w/pi, imag(H)); grid;


title('Imaginary part of H(e^{j\omega})');
xlabel('\omega/\Pi');
ylabel('Amplitude');
figure(2);
subplot(2,1,1);
plot(w/pi, abs(H)); grid;
title('Magnitude Spectrum of H(e^{j\omega})');
xlabel('\omega/\Pi');
ylabel('Amplitude');
subplot(2,1,2);
plot(w/pi, angle(H)); grid;
title('Phase Spectrum of H(e^{j\omega})');
xlabel('\omega/\Pi');
ylabel('Phase in Radians');
Out Put:-

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 24

Digital Signal Processing Lab

Digital Signal Processing Lab

GNCSGI Jabalpur

2014

Page 25

Digital Signal Processing Lab

2014

9. convolution property of DTFT.

Aim: - verifying the convolution property of DTFT.


Equipments:Operating System Windows XP
Constructor - Simulator
Software - MATLAB 7

Theory:- As we know that if two sequences are convolved in time


domain than their frequency responses i.e. DTFT multiplies in frequency
domain to demonstrate this property we first convolve two sequences
and will find Fourier transform of convolution, on the other side we
separately find the discrete time Fourier transform of two sequences and
then multiply both of them to prove the convolution property of DTFT.
Basic Matlab function used will be the same i.e. freqz.
Program:% Digital signal processing Lab
% Demonstration of convolution property of DTFT
% x1 = [1 3 5 7 9 11 13 15 17]
% x2 = [1 -2 3 -2 1]
close all;
clear all;
clc;
clf;
w= -pi:2*pi/255:pi;
x1 = [1 3 5 7 9 11 13 15 17];
x2 = [1 -2 3 -2 1];
y = conv(x1,x2);
H1 = freqz(x1,1,w);
H2 = freqz(x2,1,w);
Hp = H1.*H2;
H3 = freqz(y,1,w);
subplot(2,2,1);
plot(w/pi,abs(Hp));
grid;
title('Magnitude spectrum of convolved sequence Hp(e^{j\omega})');
Digital Signal Processing Lab

GNCSGI Jabalpur

Page 26

Digital Signal Processing Lab

2014

xlabel('\omega/\Pi');
ylabel('Amplitude');
subplot(2,2,2);
plot(w/pi,abs(H3));
grid;
title('Product of magnitude spectrum H3(e^{j\omega})');
xlabel('\omega/\Pi');
ylabel('Amplitude');
subplot(2,2,3);
plot(w/pi,angle(Hp));
grid;
title('Phase spectrum of convolved sequence Hp(e^{j\omega})');
xlabel('\omega/\Pi');
ylabel('Angle in Radian');
subplot(2,2,4);
plot(w/pi,angle(H3));
grid;
title('Phase spectrum of Product of Phase spectrum H3(e^{j\omega})');
xlabel('\omega/\Pi');
ylabel('Angle in Radian');
Out Put:-

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 27

Digital Signal Processing Lab

2014

10. Designing of Fir Low Pass Filter

Aim:- To implement FIR Low Pass Filter Using Windowing


Equipments:Operating System Windows XP or above version
Constructor script or Simulator
Software - MATLAB 7 or above version

Theory:Desired magnitude response of the ideal filter is given by the equation


(

Where is shift =(N-1)/2 where N= length of window (odd)


And c = cut off frequency of LPF
|H(ej)
|

Figure 1 Frequency response of FIR low pass filter with cutoff frequency c

Corresponding impulse response of LPF will be:


( )

Digital Signal Processing Lab

(
(

)
)

GNCSGI Jabalpur

Page 28

Digital Signal Processing Lab

2014

( )
Where N is length of window having odd length
Program:clc;
clf;
close all;
clear all;
clc;
% designing of LPF using Hamming window
% take cut off frequency wp as input
% h(n)= sin[wp(n-t)]/pi*(n-t) when n != t
% h(n)= wp/pi
when n=t
f=input('Give cutoff frequency in hertz between 0 to 4kHZ
wp=pi*f/4000;
N = 1025;
t=(N-1)/2;
n=0:N-1;
h1=sin(wp*(n-t));
h2=(pi*(n-t));
h1((n-t)==0)=wp;
h2((n-t)==0)=pi;
h=h1./h2;
stem(n,h);
title('impulse response of filter');
xlabel('sampel number');
ylabel('Amplitude');
w = 0.54-0.46*(cos(2*pi*n/(N-1)));
figure(2);
stem(n,w);
title('Hamming window');
xlabel('sampel number');
ylabel('Amplitude');
y=h.*w;
figure(3);
stem(n,y);
title('impulse response of filter h(n)*w(n)');
xlabel('sampel number');
ylabel('Amplitude');
z=fftshift(abs(fft(y)));
f=-4000:(8000/1024):4000;
figure(4)
plot(f,z);
xlabel('frequency in hertz');
Digital Signal Processing Lab

GNCSGI Jabalpur

');

Page 29

Digital Signal Processing Lab

2014

ylabel('Amplitude Spectrum');
title('Amplitude spectrum of FIR LPF');

Out Put:-

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 30

Digital Signal Processing Lab

2014

Aim:- To implement FIR High Pass Filter Using Windowing


Equipments:Operating System Windows XP or above version
Constructor script or Simulator
Software - MATLAB 7 or above version

Theory:Desired magnitude response of the ideal filter is given by the equation


(

)
(

Where is shift =(N-1)/2 where N= length of window


And c = cut off frequency of HPF
(

Corresponding impulse response of LPF will be:


( )

(
(

)
)
( )

Where N is length of window having odd length

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 31

Digital Signal Processing Lab

2014

Program:clc;
clf;
close all;
clear all;
clc;
% designing of HPF using Hamming window
% take cut off frequency wp as input
% h(n)= -sin[wc(n-t)]/pi*(n-t) when n != t
% h(n)= pi-wc/pi
when n=t
f=input('Give cutoff frequency in hertz between 0 to 4kHZ
wc=pi*f/4000;
N = 1025;
t=(N-1)/2;
n=0:N-1;
h1=-sin(wc*(n-t));
h2=(pi*(n-t));
h1((n-t)==0)=pi-wc;
h2((n-t)==0)=pi;
h=h1./h2;
stem(n,h);
title('impulse response of filter');
xlabel('sampel number');
ylabel('Amplitude');
w = 0.54-0.46*(cos(2*pi*n/(N-1)));
figure(2);
stem(n,w);
title('Hamming window');
xlabel('sampel number');
ylabel('Amplitude');
y=h.*w;
figure(3);
stem(n,y);
title('impulse response of filter h(n)*w(n)');
xlabel('sampel number');
ylabel('Amplitude');
z=fftshift(abs(fft(y)));
f=-4000:(8000/1024):4000;
figure(4)
plot(f,z);
xlabel('frequency in hertz');
ylabel('Amplitude Spectrum');
title('Amplitude spectrum of FIR HPF');

Digital Signal Processing Lab

GNCSGI Jabalpur

');

Page 32

Digital Signal Processing Lab

2014

Results:

Digital Signal Processing Lab

GNCSGI Jabalpur

Page 33

You might also like